1 Introduction

Cellular automata (CA) are discrete dynamical systems introduced by Von Neumann and Ulam, in the late 1940s [1]. Since then many applications in natural sciences and mathematics were developed, for example, in fluid dynamics with lattice Boltzmann methods [2, 3], fluids in heterogeneous porous media [4], in genetics [7], dune dynamics [5], spatial pattern formation [6], and many others [8]. Cellular automata can be seen as an idealization of a physical system in which space, time, and certain physical quantities take a finite set of values. Cellular automata provide simple models of complex systems showing that collective complex behavior can emerge from the composition or interaction of simple components. Even if the local interactions are perfectly described in a direct manner, it is possible that the global behavior of a system obeys unexpected patterns. This fact makes CA suitable to model and simulate non-equilibrium systems. In the 1980s, Wolfram [9, 10] gave a classification of cellular automata which produces an intuitive way to distinguish the dynamical behavior of cellular automata in four distinct classes, accordingly: Class 1: almost every initial conditions produce an eventually fixed point behavior. Class 2: almost every initial conditions produce an eventually periodic behavior. Class 3: almost every initial conditions produce a pseudo-random behavior. Class 4: almost every initial conditions produce a complex behavior articulating regular patterns with structured non-periodic geometric patterns.

A very detailed comparison of the CA methods, for practical fluid-dynamics problems, with conventional methods from numerical analysis is explained in [11], in particular, with details from a computational point of view, considering memory usage, computational time, and other characteristics.

Nevertheless, most of the interest in the use of cellular automata focuses on non-equilibrium fluids or fluids composed with different phases, in which the differential equations are hard to implement.

In [12] were introduced and discussed several techniques to explore evolutionary dynamics of the automata space, using biologically motivated concepts. In particular, specific genetic algorithms and techniques such as mutation, assembly, and recombination of CA. In that context the code rule of a CA was called the genotype, and the diverse characteristics of generic CA realizations were called phenotype. Here, these denominations are changed and adapted to the present context. The advantage of evolutionary methods is to efficiently obtain CA rules with specific characteristics. Previous work on evolutionary search over cellular automata can be found also in [13, 14].

In this paper are presented techniques for modeling systems, seen as idealized fluids, where may coexist distinct substances in diverse phases. These techniques, using cellular automata, are suitable to simulate transient, non-equilibrium behavior in fluid mechanics or other phenomena, such as fracture dynamics on heterogeneous materials.

Our main result is the development of the assembly method, introduced in [12], to determine CA code rules of increasing complex behavior. This means that the systems present an increasing number of distinct behavior and spatial-temporal patterns. A canonical process of assembling two CA rules is defined. This method allows the study of the singular perturbation of a complex fluid and the study of the interaction between two similar fluids subject to instabilities, leading to global phase transitions.

In Sect. 2 the notions and concepts used in the paper regarding cellular automata are introduced, in particular those notions from [12], such as the singular perturbation, assembly, and the canonical assembly. The basic CA rule 3E6IGS58S, which is used in the simulations, is also defined. In Sect. 3, the computation of the canonical assembly of the CA rule 3E6IGS58S, its variations, and the simulations of its perturbations are presented.

2 Preliminaries and Definitions

Some notions regarding one dimension cellular automata are here introduced. Let \(\mathbb {Z}_{n}=\left \{ 0,1,2,\ldots ,n-1\right \} \), n > 0, be the local state space. Let \(\phi :\mathbb {Z}_{n}^{m}\rightarrow \mathbb {Z}_{n}\) be a map, which determines the local dynamics of the system and is called local map or CA rule. An element in \(\mathbb {Z}_{n}^{m}\), i.e., a word or a block of size m in the alphabet \(\mathbb {Z}_{n}\) , is called a local configuration. The map ϕ induces a block map ϕ k, \(k\in \mathbb {N}\), which transforms words in \(\mathbb {Z} _{n} \), of size m + k, into words of size k, through

$$\displaystyle \begin{aligned} \left. \begin{array}{c} \phi _{k}:\mathbb{Z}_{n}^{m+k}\rightarrow \mathbb{Z}_{n}^{k}, \\ \\ \phi _{k}\left( x_{1}\ldots x_{m+k}\right) :=\phi \left( x_{1}\ldots x_{m}\right) \phi \left( x_{1}\ldots x_{m}\right) \ldots\phi \left( x_{1}\ldots x_{m}\right). \end{array} \right. \end{aligned}$$

There is a natural identification of ϕ 1 with ϕ. To simplify the exposition, consider m to be an odd number so that m = 2r + 1, for a certain natural number r. The global map is then defined by

$$\displaystyle \begin{aligned} \left. \begin{array}{c} \Phi :\mathbb{Z}_{n}^{\mathbb{I}}\rightarrow \mathbb{Z}_{n}^{\mathbb{I}}, \\ \\ \Phi \left( x\right) :=\left( \phi \left( x_{\left[ j-r,j+r\right] }\right) \right) _{j\in \mathbb{I}}\text{,} \end{array} \right. \end{aligned}$$

where \(\mathbb {I}\) can be \(\mathbb {Z}\), \(\mathbb {N}\) or a finite set \( \mathbb {Z}_{L}=\left \{ 1,2,\ldots ,L\right \} \). A cellular automaton is the specification of the number of local states n, the size of the local configuration m, the local map or CA rule ϕ, the configuration space or global state space \(\mathbb {I}\), and if needed, the boundary conditions which depend naturally on \(\mathbb {I}\) and m. The time evolution of the system is given by the iteration of the map Φ, given an initial condition \(x\left ( 0\right ) =\left ( x_{i}\left ( 0\right ) \right ) _{i\in \mathbb {I}}\in \mathbb {Z}_{n}^{\mathbb {I}}\),

$$\displaystyle \begin{aligned} \left. \begin{array}{c} x\left( t+1\right) =\Phi \left( x\left( t\right) \right), t\geq 0, \\ x\left( 0\right) =\left( x_{i}\left( 0\right) \right) _{i\in \mathbb{I}}\in \mathbb{Z}_{n}^{\mathbb{I}}. \end{array} \right. \end{aligned}$$

The parameter m = 2r + 1 gives the dependence of each state, in the next time instant on the states of the neighbor cells, r cells to the left and r cells to the right. In the case \(\mathbb {I}\) is \(\mathbb {N}\) or a finite set, it is necessary to specify boundary conditions, on the left in the first case and both left and right in the second case. For convenience, \(\left [ j \right ] _{n}\) denote the n-expansion of the natural number j, that is, j in base n. By convention, the number of digits in \(\left [ j\right ] _{n} \) is fixed and equal to n m. That is, if \(\left [ j\right ] _{n}=j_{1}\ldots j_{r}\) then

$$\displaystyle \begin{aligned} j=j_{1}\times n^{r-1}+j_{2}\times n^{r-2}+\cdots +j_{r-1}\times n^{1}+j_{r}\times n^{0}. \end{aligned}$$

On the other hand, a word j 1j r, in \(\mathbb {Z}_{n}^{r}\) with r ≥ 1, can be seen as a representation of a natural number \(j\in \mathbb {N }\), in base n, denoted by \(\left \langle j_{1}\ldots j_{r}\right \rangle _{n}\in \mathbb {N}\). With this notation

$$\displaystyle \begin{aligned} \begin{array}{rcl} j_{1}\ldots j_{r} & \in &\displaystyle \mathbb{Z}_{n}^{r}\rightarrow \left\langle j_{1}\ldots j_{r}\right\rangle _{n}=j\in \mathbb{N}\text{,} \\ j & \in &\displaystyle \mathbb{N}\rightarrow \left[ j\right] _{n}=j_{1}\ldots j_{r}\in \mathbb{Z }_{n}^{r}\text{.} \end{array} \end{aligned} $$

Once fixed the value m and the configuration space \(\mathbb {I}\) (and eventually the boundary condition), a cellular automaton is completely characterized specifying a sequence \(\alpha =\left ( \alpha _{1},\ldots ,\alpha _{n^{m}}\right ) \in \mathbb {Z}_{n}^{n^{m}}\) corresponding to the sequence of the images of every local configuration under ϕ. This sequence is called CA code rule and is a functional representation of the CA, that is, a particular symbol in a certain position in the referred sequence has a functional meaning. The position j in the sequence α gives a configuration which is the n-expansion of the integer (j − 1) and the value α j is the image of that configuration under the rule ϕ, that is, \(\alpha _{j}=\phi \left [ j-1\right ] _{n}\). Therefore, the CA code rule is

$$\displaystyle \begin{aligned} \alpha =\left( \phi \left[ j-1\right] _{n}\right) _{j=1}^{n^{m}}\text{.} \end{aligned}$$

A more compact way to give a particular CA code rule is to use the Wolfram numbering. The CA code rule is seen as the expansion in base n of a certain number which when converted to decimal is designated as the Wolfram number of the CA code rule. If n < 10 the number of digits of the Wolfram number is less than the number of digits corresponding to the original CA code rule; therefore it is a more compact way of specifying the CA rule. An even more compact form is to use hexadecimal base (if the number of states is less than 16), or a larger base number. Since we deal with very large CA-code rules, we will use base 32-expansion to represent the CA code rules in compact way. The base 32, similarly to base 16, uses the digit set

$$\displaystyle \begin{aligned} \{0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V\}. \end{aligned}$$

As an illustrative example consider the CA code rule 01110110 which determines the local map

$$\displaystyle \begin{aligned} \begin{array}{c} 000 \\ 0 \end{array} \ \begin{array}{c} 001 \\ 1 \end{array} \begin{array}{c} 010 \\ 1 \end{array} \begin{array}{c} 011 \\ 1 \end{array} \begin{array}{c} 100 \\ 0 \end{array} \begin{array}{c} 101 \\ 1 \end{array} \begin{array}{c} 110 \\ 1 \end{array} \begin{array}{c} 111 \\ 0 \end{array} \end{aligned}$$

The sequence 01110110 represents a number in binary. The corresponding number in decimal base is 110 = 0 × 20 + 1 × 21 + 1 × 22 + 1 × 23 + 0 × 24 + 1 × 25 + 1 × 26 + 0 × 27 (note the reversed order). In hexadecimal the rule 110 is designated by 6E, and in base 32 is 3E. See Figs. 1 and 2.

Fig. 1
figure 1

Explicit CA code rule 110, in Wolfram numbering

Fig. 2
figure 2

Example of a realization of the automaton rule 110

To resume, a CA code rule will be a sequence \(\alpha =\alpha _{1}\alpha _{2}\ldots \alpha _{n^{m}}\in \mathbb {Z}_{n}^{n^{m}}\), with \(n\in \mathbb {N}\). The space of the CA code rules is denoted by \({G}\). The space of CA code rules which have n different symbols is denoted by \(\mathcal {G}_{n}\), and the space of CA code rules which have n different symbols and with neighbor number equal to m is denoted by \(\mathcal {G}_{n,m}\).

The cellular automaton which is central in this work is a 3-state rule, with m = 3 and \(\mathbb {I}=\mathbb {Z}_{L}\), for a certain natural L. The CA code rule is

$$\displaystyle \begin{aligned} \alpha =202000211011010222222101111. \end{aligned}$$

The local map in \(\mathbb {Z}_{3}=\left \{ 0,1,2\right \} \), is then defined by

$$\displaystyle \begin{aligned} \begin{array}{c} 000 \\ \downarrow \\ 2 \end{array} \ \begin{array}{c} 001 \\ \downarrow \\ 0 \end{array} \begin{array}{c} 002 \\ \downarrow \\ 2 \end{array} \begin{array}{c} 010 \\ \downarrow \\ 0 \end{array} \begin{array}{c} 011 \\ \downarrow \\ 0 \end{array} \begin{array}{c} 012 \\ \downarrow \\ 0 \end{array} \begin{array}{c} 020 \\ \downarrow \\ 2 \end{array} \begin{array}{c} 021 \\ \downarrow \\ 1 \end{array} \begin{array}{c} 022 \\ \downarrow \\ 1 \end{array} \end{aligned}$$
$$\displaystyle \begin{aligned} \begin{array}{c} 100 \\ \downarrow \\ 0 \end{array} \ \begin{array}{c} 101 \\ \downarrow \\ 1 \end{array} \begin{array}{c} 102 \\ \downarrow \\ 1 \end{array} \begin{array}{c} 110 \\ \downarrow \\ 0 \end{array} \begin{array}{c} 111 \\ \downarrow \\ 1 \end{array} \begin{array}{c} 112 \\ \downarrow \\ 0 \end{array} \begin{array}{c} 120 \\ \downarrow \\ 2 \end{array} \begin{array}{c} 121 \\ \downarrow \\ 2 \end{array} \begin{array}{c} 122 \\ \downarrow \\ 2 \end{array} \end{aligned}$$
$$\displaystyle \begin{aligned} \begin{array}{c} 200 \\ \downarrow \\ 2 \end{array} \ \begin{array}{c} 201 \\ \downarrow \\ 2 \end{array} \begin{array}{c} 202 \\ \downarrow \\ 2 \end{array} \begin{array}{c} 210 \\ \downarrow \\ 1 \end{array} \begin{array}{c} 211 \\ \downarrow \\ 0 \end{array} \begin{array}{c} 212 \\ \downarrow \\ 1 \end{array} \begin{array}{c} 220 \\ \downarrow \\ 1 \end{array} \begin{array}{c} 221 \\ \downarrow \\ 1 \end{array} \begin{array}{c} 222 \\ \downarrow \\ 1 \end{array} \end{aligned}$$

The corresponding natural number (in decimal base), Wolfram number, is

$$\displaystyle \begin{aligned} \begin{array}{rcl} 3786635351324 & =&\displaystyle 2\times 3^{0}+0\times 3^{1}+2\times 3^{2}+0\times 3^{3}+0\times 3^{4}+0\times 3^{5} \\ & +&\displaystyle 2\times 3^{6}+1\times 3^{7}+1\times 3^{8}+0\times 3^{9}+1\times 3^{10}+1\times 3^{11} \\ & +&\displaystyle 0\times 3^{12}+1\times 3^{13}+0\times 3^{14}+2\times 3^{15}+2\times 3^{16}+2\times 3^{17} \\ & +&\displaystyle 2\times 3^{18}+2\times 3^{19}+2\times 3^{20}+1\times 3^{21}+0\times 3^{22}+1\times 3^{23} \\ & +&\displaystyle 1\times 3^{24}+1\times 3^{25}+1\times 3^{26}. \end{array} \end{aligned} $$

Note that the same number in base 2 is the CA code rule in reversed order, that is,

$$\displaystyle \begin{aligned} 111101222222010110112000202_{binary}=3786635351324_{decimal}. \end{aligned}$$

In a more compact description, its hexadecimal representation is 371A50E151C and in 32-base is 3E6IGS58S. This last representation will be chosen to refer the CA rule, since it is shorter. In Fig. 3 we present an example of a realization with initial global state given by a random vector \(x_{0}\in \mathbb {Z}_{3}^{150}\).

Fig. 3
figure 3

Realization of CA rule 3E6IGS58S, with random initial conditions

2.1 Singular Perturbation and Pattern Stability

A singular perturbation of the CA rule is a transformation in a single symbol of the CA code rule, and it is the simplest possible transformation defined on the rule space \(\mathcal {G}_{n,m}\). This perturbation can be generated randomly or generated by a deterministic process. To give a singular perturbation, it is necessary to specify the position in the CA code rule where the mutation is to occur and how it occurs. Recall that a position j in the sequence α gives a configuration which is the n −expansion of the integer \(\left ( j-1\right ) \), that is, \(\left [ j-1\right ] _{n}\), (00…00 is the configuration of the position 1), and the value α j is the image of the configuration under the automaton ϕ, that is, \(\alpha _{j}=\phi \left [ j-1\right ] _{n}\), j = 1, …, n m.

Now, consider the stability of the patterns produced by time evolution of an initial condition, with respect to singular perturbation. There are several cellular automata which are very robust under singular perturbation, regarding the geometric structure of the patterns produced, and others very sensitive. However, some CA are robust to singular perturbation in some positions and in other positions are strongly sensitive. As an example of this phenomena, see the Figs. 4, 5, 6, 7, and 8. The same CA code rule 3E6IGS58S is singularly perturbed in different positions, and for each case a realization of the CA is obtained, with random initial conditions. The realizations show the similarity of some of the mutated CA codes and the drastic changes in others.

Fig. 4
figure 4

(a) Realization of the CA rule 3E6IGS58S. (b) Realization of a perturbation of the CA rule 3E6IGS58S at position 23

Fig. 5
figure 5

(a) Realization of the CA rule 3E6IGS58S. (b) Realization of a perturbation of the CA rule 3E6IGS58S at position 23, with random initial conditions

Fig. 6
figure 6

(a) Realization of the CA rule 3E6IGS58S. (b) Realization of a perturbation of the CA rule 3E6IGS58S at position 23

Fig. 7
figure 7

(a) Realization of the CA rule 3E6IGS58S. (b) Realization of a perturbation of the CA rule 3E6IGS58S at position 23

Fig. 8
figure 8

(a) Realization of the CA rule 3E6IGS58S. (b) Realization of a perturbation of the CA rule 3E6IGS58S at position 23

2.2 Assembly of CA Code Rules

Next, it is described the assembly technique which produces CA rules obtained from two given CA rules. The assembled CA rule inherits several characteristics from the original rules; in particular, it maintains the original CA as subcases for special initial conditions. Let \(\alpha =\alpha _{1}\ldots \alpha _{p^{m}}\in \mathcal {G}_{p,m}\) and \(\beta =\beta _{1}\ldots \beta _{q^{m}}\in \mathcal {G}_{q,m}\) be two CA code rules with \(p,q,m\in \mathbb {N} \). The alphabet underlying \(\mathcal {G}_{p,m}\) is, as usual \(\mathbb {Z}_{p}\) , and for \(\mathcal {G}_{q,m}\) is \(\mathbb {Z}_{q}\). The assembly of α with β is a general procedure which gives a class of CA code rules in the space \(\mathcal {G}_{n,m}\), where n = p + q.

The first p symbols of \(\mathbb {Z}_{n}\) are reserved to codify the rule α and the last q symbols of \(\mathbb {Z}_{n}\) to codify the rule β, using the correspondence

$$\displaystyle \begin{aligned} \begin{array}{c} \mathbb{Z}_{p} \\ \downarrow \\ \mathbb{Z}_{n} \end{array} \ \begin{array}{ccc} 0 & \ldots & p-1 \\ \downarrow & & \downarrow \\ 0 & \ldots & p-1 \end{array} \ \ \text{and }\ \ \begin{array}{c} \mathbb{Z}_{q} \\ \downarrow \\ \mathbb{Z}_{n} \end{array} \ \begin{array}{ccc} 0 & \ldots & q-1 \\ \downarrow & & \downarrow \\ p & \ldots & p+q \end{array} \end{aligned}$$

Denote the correspondence \(\widehat {}:\mathbb {Z}_{q}\rightarrow \left \{ p,\ldots ,p+q\right \} \subset \mathbb {Z}_{n}\) and the reversed correspondence \(\widetilde {}:\left \{ p,\ldots ,p+q\right \} \rightarrow \mathbb {Z}_{q}\). Note that \(\widehat {}\) can be seen as adding p to each symbol if each symbol is seen as a natural number. For each local configuration \(i_{1}\ldots i_{m}\in \mathbb {Z}_{p}^{m}\), corresponding to the CA code rule \(\alpha \in \mathcal {G}_{p,m}\), it is associated the same configuration (with the same symbols) in \(\mathbb {Z}_{n}^{m}\). To each configuration \(j_{1}\ldots j_{m}\in \mathbb {Z}_{q}^{m}\), corresponding to the CA code rule \(\beta \in \mathcal {G}_{q,m}\) it is associated the configuration \( \widehat {j}_{1}\ldots \widehat {j}_{m}\) in \(\mathbb {Z}_{n}^{m}\). This gives a large number of degrees of freedom to choose the image of the local map associated with configurations which mix symbols from \(\left \{ 0,\ldots ,p-1\right \} \) and \(\left \{ p,\ldots ,p+q\right \} \). This means that there are many different CA code rules arising from assembly of two specific CA code rules α, β, .

Let ϕ α,ϕ β, ϕ γ denote the local rules for each CA code rule α, β, γ. Then γ is a CA code rule assembly of α, β if the following property is Satisfied:

$$\displaystyle \begin{aligned} x_{1}\ldots x_{m}\in \left\{ 0,\ldots,p-1\right\} ^{m}\Rightarrow \phi _{\gamma }\left( x_{1}\ldots x_{m}\right) =\phi _{\alpha }\left( x_{1}\ldots x_{m}\right) \text{, } \end{aligned}$$
$$\displaystyle \begin{aligned} x_{1}\ldots x_{m}\in \left\{ p,\ldots,p+q\right\} ^{m}\Rightarrow \phi _{\gamma }\left( x_{1}\ldots x_{m}\right) =\phi _{\beta }\left( \widetilde{x}_{1}\ldots \widetilde{x}_{m}\right) \text{. } \end{aligned}$$

The local configurations for ϕ γ with digits exclusively from \( \left \{ 0,\ldots ,p-1\right \}\) or exclusively \(\left \{ p,\ldots ,p+q\right \} \) are called pure local configurations; the local configurations mixing digits from \(\left \{ 0,\ldots ,p-1\right \} \) and \(\left \{ p,\ldots ,p+q\right \} \) are called mixed local configurations. The images under ϕ γ of pure local configurations in \(\left \{ 0,\ldots ,p-1\right \} \) are determined by ϕ α, and the images under ϕ γ of pure local configurations in \(\left \{ p,\ldots ,p+q\right \} \) are determined by ϕ β. The images under ϕ γ of the mixed configurations are not determined by α, β. Therefore, must be as external parameters or degrees of freedom. As an example, consider the CA code rules \(\alpha \in \mathcal {G}_{2,3}\), rule 18, and \(\beta \in \mathcal {G}_{2,3}\), rule 110, given by

$$\displaystyle \begin{aligned} \alpha =01001000\ \ \ \text{and}\ \ \ \beta =01110110. \end{aligned}$$

The second CA code rule, β, is transformed via \(0\rightarrow \widehat {0}=2\) and \(1\rightarrow \widehat {1}=3\) into

$$\displaystyle \begin{aligned} \widehat{\beta }=23332332\text{.} \end{aligned}$$

Note that the cellular automata β and \(\widehat {\beta }\) are equivalent, although the symbols are distinct; therefore, the two automata are identified \(\beta \longleftrightarrow \widehat {\beta }\).

Consider a CA code rule \(\gamma \in \mathcal {G}_{4,3}\) obtained by assembly of α and β. Therefore, corresponds to a cellular automaton that when restricted to initial conditions (and boundary conditions) with states 0, 1 will reproduce the exact patterns of α and when restricted to initial conditions (and eventual boundary conditions) with states 3, 4 will reproduce the patterns of β (up to the transformation 0 → 3, 1 → 4). A CA code rule γ satisfying this property is called the assembly of α and β. There are many different CA code rules arising from assembly. The local map in \(\mathbb {Z}_{4}=\left \{ 0,1,2,3\right \} \), for a rule \(\gamma \in \mathcal {G}_{4,3}\), assembly of α and β has the following structure:

$$\displaystyle \begin{aligned} \begin{array}{c} 000 \\ \downarrow \\ \gamma _{1}=\alpha _{1} \end{array} \ \begin{array}{c} 001 \\ \downarrow \\ \gamma _{2}=\alpha _{2} \end{array} \begin{array}{c} 002 \\ \downarrow \\ \gamma _{3} \end{array} \begin{array}{c} 003 \\ \downarrow \\ \gamma _{4} \end{array} \begin{array}{c} 010 \\ \downarrow \\ \gamma _{5}=\alpha _{3} \end{array} \begin{array}{c} 011 \\ \downarrow \\ \gamma _{6}=\alpha _{4} \end{array} \begin{array}{c} 012 \\ \downarrow \\ \gamma _{7} \end{array} \begin{array}{c} 013 \\ \downarrow \\ \gamma _{8} \end{array} \end{aligned}$$
$$\displaystyle \begin{aligned} \begin{array}{c} 020 \\ \downarrow \\ \gamma _{9} \end{array} \ \ \begin{array}{c} 021 \\ \downarrow \\ \gamma _{10} \end{array} \ \ \begin{array}{c} 022 \\ \downarrow \\ \gamma _{11} \end{array} \ \ \begin{array}{c} 023 \\ \downarrow \\ \gamma _{12} \end{array} \ \ \begin{array}{c} 030 \\ \downarrow \\ \gamma _{13} \end{array} \ \ \begin{array}{c} 031 \\ \downarrow \\ \gamma _{14} \end{array} \ \ \begin{array}{c} 032 \\ \downarrow \\ \gamma _{15} \end{array} \ \ \begin{array}{c} 033 \\ \downarrow \\ \gamma _{16} \end{array} \end{aligned}$$
$$\displaystyle \begin{aligned} \begin{array}{c} 100 \\ \downarrow \\ \gamma _{17}=\alpha _{5} \end{array} \ \begin{array}{c} 101 \\ \downarrow \\ \gamma _{18}=\alpha _{6} \end{array} \begin{array}{c} 102 \\ \downarrow \\ \gamma _{19} \end{array} \begin{array}{c} 103 \\ \downarrow \\ \gamma _{20} \end{array} \begin{array}{c} 110 \\ \downarrow \\ \gamma _{21}=\alpha _{7} \end{array} \begin{array}{c} 111 \\ \downarrow \\ \gamma _{22}=\alpha _{8} \end{array} \begin{array}{c} 112 \\ \downarrow \\ \gamma _{23} \end{array} \begin{array}{c} 113 \\ \downarrow \\ \gamma _{24} \end{array} \end{aligned}$$
$$\displaystyle \begin{aligned} \begin{array}{c} 120 \\ \downarrow \\ \gamma _{25} \end{array} \begin{array}{c} 121 \\ \downarrow \\ \gamma _{26} \end{array} \begin{array}{c} 122 \\ \downarrow \\ \gamma _{27} \end{array} \begin{array}{c} 123 \\ \downarrow \\ \gamma _{28} \end{array} \begin{array}{c} 130 \\ \downarrow \\ \gamma _{29} \end{array} \begin{array}{c} 131 \\ \downarrow \\ \gamma _{30} \end{array} \begin{array}{c} 132 \\ \downarrow \\ \gamma _{31} \end{array} \begin{array}{c} 133 \\ \downarrow \\ \gamma _{32} \end{array} \end{aligned}$$
$$\displaystyle \begin{aligned} \begin{array}{c} 200 \\ \downarrow \\ \gamma _{33} \end{array} \ \begin{array}{c} 201 \\ \downarrow \\ \gamma _{34} \end{array} \begin{array}{c} 202 \\ \downarrow \\ \gamma _{35} \end{array} \begin{array}{c} 203 \\ \downarrow \\ \gamma _{36} \end{array} \begin{array}{c} 210 \\ \downarrow \\ \gamma _{371} \end{array} \begin{array}{c} 211 \\ \downarrow \\ \gamma _{38} \end{array} \begin{array}{c} 212 \\ \downarrow \\ \gamma _{39} \end{array} \begin{array}{c} 213 \\ \downarrow \\ \gamma _{40} \end{array} \end{aligned}$$
$$\displaystyle \begin{aligned} \begin{array}{c} 220 \\ \downarrow \\ \gamma _{41} \end{array} \begin{array}{c} 221 \\ \downarrow \\ \gamma _{42} \end{array} \begin{array}{c} 222 \\ \downarrow \\ \gamma _{43}=\widehat{\beta }_{1} \end{array} \begin{array}{c} 223 \\ \downarrow \\ \gamma _{44}=\widehat{\beta }_{2} \end{array} \begin{array}{c} 230 \\ \downarrow \\ \gamma _{45} \end{array} \begin{array}{c} 231 \\ \downarrow \\ \gamma _{46} \end{array} \begin{array}{c} 232 \\ \downarrow \\ \gamma _{47}=\widehat{\beta }_{3} \end{array} \begin{array}{c} 233 \\ \downarrow \\ \gamma _{48}=\widehat{\beta }_{4} \end{array} \end{aligned}$$
$$\displaystyle \begin{aligned} \begin{array}{c} 300 \\ \downarrow \\ \gamma _{49} \end{array} \ \begin{array}{c} 301 \\ \downarrow \\ \gamma _{50} \end{array} \begin{array}{c} 302 \\ \downarrow \\ \gamma _{51} \end{array} \begin{array}{c} 303 \\ \downarrow \\ \gamma _{52} \end{array} \begin{array}{c} 310 \\ \downarrow \\ \gamma _{53} \end{array} \begin{array}{c} 311 \\ \downarrow \\ \gamma _{54} \end{array} \begin{array}{c} 312 \\ \downarrow \\ \gamma _{55} \end{array} \begin{array}{c} 313 \\ \downarrow \\ \gamma _{56} \end{array} \end{aligned}$$
$$\displaystyle \begin{aligned} \begin{array}{c} 320 \\ \downarrow \\ \gamma _{57} \end{array} \begin{array}{c} 321 \\ \downarrow \\ \gamma _{58} \end{array} \begin{array}{c} 322 \\ \downarrow \\ \gamma _{59}=\widehat{\beta }_{5} \end{array} \begin{array}{c} 323 \\ \downarrow \\ \gamma _{60}=\widehat{\beta }_{6} \end{array} \begin{array}{c} 330 \\ \downarrow \\ \gamma _{61} \end{array} \begin{array}{c} 331 \\ \downarrow \\ \gamma _{62} \end{array} \begin{array}{c} 332 \\ \downarrow \\ \gamma _{63}=\widehat{\beta }_{7} \end{array} \begin{array}{c} 333 \\ \downarrow \\ \gamma _{64}=\widehat{\beta }_{8} \end{array} \end{aligned}$$

In Fig. 9 are shown three realizations of distinct CA-rules in \(\mathcal {G}_{4,3}\) arising from the assembly of α and β. From left to right are denoted by \(\gamma ^{\left ( 1\right ) }\), \( \gamma ^{\left ( 2\right ) }\), and \(\gamma ^{\left ( 3\right ) }\). The initial conditions are composed by two segments with random initial conditions from {0, 1}, and the middle segment is generated randomly from {2, 3}. The difference between the rules \(\gamma ^{\left ( 1\right ) }\), \(\gamma ^{\left ( 2\right ) }\) and \(\gamma ^{\left ( 3\right ) }\) are that for γ (1) the values of the rule for mixed local configurations are taken randomly only from {0, 1} which means that the patterns arising from α dominate. For γ (2) the values of the rule for mixed local configurations are taken randomly only from {2, 3} which means that the patterns arising from β dominate. Finally, for γ (3) the values of the rule for mixed local configurations are taken randomly only from {0, 1, 2, 3} with equal probability, which means that the initial patterns arising from α and β mix and interact along the time flow.

Fig. 9
figure 9

Distinct assembly of rule 18 with rule 110: (a) Realization for \( \gamma ^{ \left ( 1 \right ) }.\) (b) Realization for \( \gamma ^{ \left ( 2 \right ) }.\) (c) Realization for \( \gamma ^{ \left ( 3 \right ) }\)

The examples shown in Fig. 9, with α = 01001000 and β = 01110110, correspond to

$$\displaystyle \begin{aligned} \gamma ^{\left( 1\right) }=0112001120110101101100200111012000101000022311331001101202232132, \end{aligned}$$

with a majority of states for mixed configurations taken randomly from {0, 1},

$$\displaystyle \begin{aligned} \gamma ^{\left( 2\right) }=0122001322123301103200332232312232321203022331331203321232232132, \end{aligned}$$

with a majority of states for mixed configurations taken randomly from {2, 3},

$$\displaystyle \begin{aligned} \gamma ^{\left( 3\right) }=0132003130120123101100230113312000201000022313331023103232232132, \end{aligned}$$

with an equilibrium of states for mixed configurations taken randomly with probability 1∕2 from {0, 1} and {2, 3}.

2.3 Canonical Assembly of a CA Rule

Consider now a process to assembly two copies of the same CA rule. In this case, it is possible to turn the assembly uniquely determined, that is, not depending on externally given parameters. Therefore, this process is called canonical assembly. The canonical assembly can be viewed as the embedding of a particular system in a larger one containing two copies of the original system. This process is particularly important if it is necessary to model a system in non-equilibrium which is transforming and exhibiting new patterns of behavior although maintaining others. This can be achieved allowing singular perturbations after a canonical assembly, as it is seen in the next section.

Let \(\alpha \in \mathcal {G}_{p,m}\) and n = 2p. Consider the state transformations

$$\displaystyle \begin{aligned} \widehat{}:\mathbb{Z}_{n}\rightarrow \mathbb{Z}_{n}\ \text{and }\ \widetilde{}:\mathbb{Z}_{n}\rightarrow \mathbb{Z}_{n}, \end{aligned}$$

with

$$\displaystyle \begin{aligned} \widehat{0}=p,\widehat{1}=p+1,\ldots ,\widehat{p-1}=2p-1,\ \ \widehat{p}=p,\widehat{p+1}=p+1,\ldots ,\widehat{2p-1}=2p-1, \end{aligned}$$

and

$$\displaystyle \begin{aligned} \widetilde{0}=0,\widetilde{1}=1,\ldots ,\widetilde{p-1}=p-1,\ \ \ \widetilde{p}=0,\widetilde{p+1}=1,\ldots ,\widetilde{2p-1}=p-1\text{.} \end{aligned}$$

Note that \(\widehat {\mathbb {Z}_{n}}=\{p,p+1,\ldots ,2p-1\}\) and \(\widetilde { \mathbb {Z}_{n}}=\mathbb {Z}_{p}=\{0,1,\ldots ,p-1\}\). Moreover, \(\widetilde { \widehat {x}}=x\) and \(\widehat {\widetilde {x}}=x\).

Let \(N_{X}\left ( i_{1}i_{2}\ldots i_{m}\right ) \) be the number of digits in i 1 i 2i m belonging to a certain subset \(X\subset \mathbb {Z}_{n}\). Let

$$\displaystyle \begin{aligned} \chi \left( i_{1}i_{2}\ldots i_{m}\right) =\left\{ \begin{array}{l} 0\text{ if }N_{\mathbb{Z}_{p}}\left( i_{1}i_{2}\ldots i_{m}\right) >r, \\ 1\text{ if }N_{\mathbb{Z}_{p}}\left( i_{1}i_{2}\ldots i_{m}\right) \leq r. \end{array} \right. \end{aligned}$$

Recall that r = m∕2 − 1. The condition above simply determines if the number of digits in i 1 i 2i m belonging to \(\mathbb {Z}_{p}\) is larger than the number of digits in \(\left \{ p,p+1,\ldots ,n-1\right \} \), with n = 2p. Then the canonical assembly of α produces a CA code rule \(\gamma =\left ( \gamma _{k}\right ) _{k=1,\ldots n^{m}}\) with

$$\displaystyle \begin{aligned} \gamma _{\left\langle i_{1}\ldots i_{m}\right\rangle _{n}}=\left\{ \begin{array}{l} \alpha _{\left\langle \widetilde{i}_{1}\ldots\widetilde{i}_{m}\right\rangle _{p}}\text{ if }\chi \left( i_{1}i_{2}\ldots i_{m}\right) =0, \\ \beta _{\left\langle \widetilde{i}_{1}\ldots\widetilde{i}_{m}\right\rangle _{p}} \text{ if }\chi \left( i_{1}i_{2}\ldots i_{m}\right) =1. \end{array} \right. \end{aligned}$$

where \(\beta =\widehat {\alpha }=\left ( \widehat {\alpha }_{k}\right ) _{k=1,\ldots ,p^{m}}\). Recall that \(\left \langle i_{1}\ldots i_{m}\right \rangle _{n}\) is the position number associated to the local configuration i 1i m in base n. The number \(\left \langle \widetilde {i}_{1}\ldots \widetilde {i} _{mp}\right \rangle \) is the position number associated with the local configuration \(\widetilde {i}_{1}\ldots \widetilde {i}_{m}\) in base p, since the transformation \(\widetilde {}\) sends \(\mathbb {Z}_{n}\) to \(\mathbb {Z} _{p}\). The canonical assembly produces a CA rule which in practical terms, reproduces two copies of the same CA with the duplication of the number of states.

3 Case Study: Rule 3E6IGS58S

The CA rule 3E6IGS58S (see Fig. 3) is seen as an idealized fluid where two substances which do not mix easily and two different phases of one of the substances are in unstable equilibrium. The states 0, 1 (lighter colors) are seen as the same substance in a different phase, and the state 2 (darker color) is a different substance. This phenomenon reflects on the persistency of the local state 2 in refined geometric structures and on the interaction between states 0, 1 which interchanges in a complex way.

Through the general process of the canonical assembly applied to the CA rule 3E6IGS58S, it is obtained a CA rule which models a system composed of two fluids of the same type. Moreover, the perturbation of the CA rule leads to complex behavior, where the realizations of the CA rule present the patterns of the original fluids and the patterns arising from the perturbation. In particular, the singular perturbations considered in Sect. 2.1, for the individual fluid, are applied.

3.1 Canonical Assembly of Rule 3E6IGS58S

Let p = 3, consider the 3-state CA rule 3E6IGS58S, given by

$$\displaystyle \begin{aligned} \alpha =202000211011010222222101111, \end{aligned}$$

and let

$$\displaystyle \begin{aligned} \beta =\widehat{\alpha }=535333544344343555555434444, \end{aligned}$$

which is obtained from α adding 3 to each symbol, as explained in the assembly section. Now, consider the canonical assembly of α, with

$$\displaystyle \begin{aligned} \widehat{0}=2,\widehat{1}=3,\widehat{2}=5,\widehat{3}=3,\widehat{4}=4, \widehat{5}=5, \end{aligned}$$

and

$$\displaystyle \begin{aligned} \widetilde{0}=0,\widetilde{1}=1,\widetilde{2}=2,\widetilde{3}=0,\widetilde{4} =1,\widetilde{5}=2\text{.} \end{aligned}$$

The CA code rule is, represented in base 32,

$$\displaystyle \begin{aligned} \begin{array}{rcl} & &\displaystyle { \text{8598OE44A81JS1KVBGVUQ5KDRJ7UP0JUBPL9CBFFBDIPFH1669SA00CU2}} \\ & &\displaystyle {\ldots \text{MLT0B3AI26QSATJCN6LO7PKRTSIC2QFB180IQJTCQAFIUC6CEOSMSRI.}} \end{array} \end{aligned} $$

In Fig. 10 is shown a realization of the canonical assembly of the rule, exhibiting the coexistence of the two fluids in similar regimes.

Fig. 10
figure 10

Realization for the canonical assembly of the rule with structured initial conditions: three segments randomly generated from {0, 1, 2}, from {3, 4, 5}, and again from {0, 1, 2}. Random initial conditions

3.2 Perturbations of the Canonical Assembly

In Fig. 11 it is shown the singular perturbations of the canonical assembly of the CA rule 3E6IGS58S in which there is a singular perturbation in the local configurations: 333, 5↦4, 544 , 3↦4, 554, 4↦3, showing the coexistence of the patterns of the original fluid and the patterns arising from the perturbed CA, from Sect. 2.1, Figs. 4, 5, and 6.

Fig. 11
figure 11

(a) Perturbation of the canonical assembly of rule on the local configuration 333 as in the figure (in this case local configuration 000 ). (b) Perturbation of the canonical assembly of rule on the local configuration 544 as in the figure (in this case local configuration 211 ). (c) Perturbation of the canonical assembly of rule on the local configuration 554 as in the figure (in this case local configuration 221

Finally, consider the assembly of two CA code rules with randomly chosen values for the mixed configurations. In this case, the original patterns are maintained, as long as the initial condition is restricted to pure local configuration states. If the initial conditions mix states, then there is a complex interaction between the two fluids and the patterns arising from the original CA.

This method produces CA rules which have unstable equilibrium between the two coexisting fluids as is shown in Fig. 12.

Fig. 12
figure 12

(a) Realization for γ 4, with structured initial conditions: three segments randomly generated from {0, 1, 2}, from {3, 4, 5}, and again from {0, 1, 2}. (b) Realization for γ 5, random initial conditions

4 Conclusions and Further Developments

In the present paper techniques are developed for modeling idealized fluids where coexist distinct substances in different phases. These techniques, based on cellular automata, are appropriate to simulate transient and non-equilibrium behavior in fluid mechanics. The main result is the development of the canonical assembly method which allows the determination of CA code rules with complex behavior, obtained from given initial CA rules. The systems subject to assembly present an increasing number of distinct behavior and spatial-temporal patterns, maintaining, for certain initial conditions, the original patterns. Several families of CA, associated with idealized fluid substances, are considered. The canonical assembly method allows the study of small perturbations of a complex fluid and the study of the interaction between two similar fluids subject to instabilities. It is clear that the instabilities depend on the particular rules. The considered rules are sensitive to certain singular perturbations and not to other. The systematic study of the perturbations of these rules will be considered in future work, aiming a complete classification of its behavior.