# An Environmental Perception Framework for Robotic Fish Formation Based on Machine Learning Methods
## 2 Models and Methods
### Simulation Method  
#### 2.3.1 Numerical Method  
The numerical method in this work uses an arbitrary Lagrangian-Eulerian (ALE) method [35; 36; 37] to simulate fish moving in the fluid, which is consistent with the method in our previous work [38]. The governing equations of ALE formulation for the two-dimensional viscous incompressible flow are expressed as follows:  
\[\
abla\cdot\mathbf{u}=\mathbf{0}, \tag{3}\]  
\[\frac{\partial\mathbf{u}}{\partial t}+\mathbf{c}\cdot\
abla\mathbf{u}=-\frac{\
abla P}{ \rho}+\
u\
abla^{2}\mathbf{u}+\mathbf{b}, \tag{4}\]  
where \(\rho\) and \(\
u\) denote the density and the kinematic viscosity of the fluid, respectively; \(P\) and \(\mathbf{u}\) represent the pressure and velocity of the flow, respectively; \(\mathbf{b}\) is the body force per unit mass; and \(\mathbf{c}\) is the convective velocity which represents the relative velocity between the moving mesh and the fluid. The boundary conditions are set as follows: uniform velocity at the inlet, constant static pressure and zero-gradient velocity at the outlet, slip wall at the lateral boundaries, and no-slip wall on the surface of the robotic fish. The interaction of the fish and the fluid is realized by setting a no-slip boundary condition on the robot surface and introducing a relation:  
\[\mathbf{u}_{b}=\mathbf{u}_{f}, \tag{5}\]  
where \(\mathbf{u}_{b}\) is the fish body velocity and \(\mathbf{u}_{f}\) is the fluid velocity at the surface of fish body.  
The governing equations are discretized by a finite volume approach with the second-order backward scheme in time and second-order liner scheme in space. The pressure-implicit split-operator (PISO) algorithm [39] is used to solve Equations (3) and (4) for velocity and pressure. The whole computational domain is decomposed by triangle mesh, as illustrated in Figure 1b. As the fields around the undulating fish may have a large gradient, mesh near the robotic fish is refined with high resolution. In addition, we need to obtain data such as pressure on the surface of robotic fish, so the mesh of the surface should be very fine. The surface of the fish body is composed of 230-280 cells. All simulations were based on the mesh scale from \(2.5\times 10^{5}\) to \(4.5\times 10^{5}\) cells, which passed the test of grid-independence for our two-dimensional simulations. We used a parallel dynamic mesh method based on the radial basis function to move mesh on OpenFOAM [40; 41].  
Figure 1: Illustration of the analytical description of the robotic fish body: (**a**) half outline of the body; and (**b**) mesh distribution around the body.  
In this study, we use the kinematic pressure, which is the ratio of pressure to the density of the fluid. In Equation (4), the kinematic pressure is equal to \(\
abla P/\rho\). The kinematic pressure is considered as incompressible and its absolute value is taken relative to the outlet pressure. The outlet pressure is set to 0. The parameter \(\mathbf{b}\) in Equation (4) does not include gravity, thus we do not need to consider buoyancy effects. Simply, the kinematic pressure is independent of water depth. The kinematic pressure of the robotic fish surface is caused by the disturbance of the surrounding fluid. It should be noted that, in this study, only the kinematic pressure is used in simulations and it is abbreviated as \(p\).