Mapping Spatial Patterns to Energetic Benefits in Groups of Flow-coupled Swimmers

The coordinated motion of animal groups through fluids is thought to reduce the cost of locomotion to individuals in the group. However, the connection between the spatial patterns observed in collectively moving animals and the energetic benefits at each position within the group remains unclear. To address this knowledge gap, we study the spontaneous emergence of cohesive formations in groups of fish, modeled as flapping foils, all heading in the same direction. We show in pairwise formations and with increasing group size that (1) in side-by-side arrangements, the reciprocal nature of flow coupling results in an equal distribution of energy re-quirements among all members, with reduction in cost of locomotion for swimmers flapping inphase but an increase in cost for swimmers flapping antiphase, and (2) in inline arrangements, flow coupling is non-reciprocal for all flapping phase, with energetic savings in favor of trailing swimmers, but only up to a finite number of swimmers, beyond which school cohesion and energetic benefits are lost at once. We explain these findings mechanistically and we provide efficient diagnostic tools for identifying locations in the wake of single and multiple swimmers that offer op-portunities for hydrodynamic benefits to aspiring followers. Our results imply a connection between the resources generated by flow physics and social traits that influence greedy and cooperative group behavior.


Introduction
Flow interactions are thought to allow flying and swimming animals to derive energetic benefits when moving in groups [1].However, direct assessment of such benefits is challenging, chiefly because animal groups do not generally conform to regular patterns -individuals in these groups dynamically change their position relative to their neighbors [2][3][4][5][6].Also, because direct energetic measurements in moving animals, flying or swimming, are notoriously difficult and often unreliable as proxy for hydrodynamic energy savings [4,[7][8][9][10][11][12][13].These difficulties hinder a direct mapping from the spatial pattern of the group to the energetic benefits or costs incurred at each position within the group.
An understanding of how the spatial arrangement of individuals within a group influences their cost of locomotion can provide insights into the evolution of social structures, resource allocation, and overall fitness of each individual in cooperative activities such as foraging, mating, and evasion [14][15][16][17][18][19][20].It could also guide the design of bio-inspired engineering systems and algorithms that steer groups of entities, such as swarms of autonomous robotic vehicles, underwater or in flight, that collaborate to achieve a desired task while minimizing energy consumption and improving the overall system efficiency [21][22][23][24][25].
To understand the potential energetic benefits of group movement, various direct and indirect approaches have been employed.Li et al. [9] associated energy savings in pairs of flapping robotic swimmers with a linear relationship between their flapping phase lag and relative distance.Based on this, a strategy, called Vortex Phase Matching, was extrapolated for how fish should behave to maximize hydrodynamic benefits: a follower fish should match its tailbeat phase with the local vorticity created by a leader fish.Pairs of freely swimming fish seemed to follow this linear phase-distance relationship even with impaired vision and lateral line sensing, that is, in the absence of sensory cues about their relative position and neighbor-generated flows.Interestingly, the same linear phase-distance relationship was uncovered independently in flapping hydrofoils and accredited solely to flow interactions [26][27][28].It is therefore unclear whether vortex phase matching is an active strategy, mediated by sensing and feedback control, that fish employ to minimize energy expenditure, or if it arises passively through flow interactions between flapping swimmers.Importantly, active or passive, it is unclear if this strategy scales to groups larger than two.
In an effort to directly gauge the energetic benefits of schooling, metabolic energetic measurements were recently performed in solitary and groups of eight fish, and impressive energetic savings were attributed to schooling compared to solitary swimming when the fish were challenged to swim at high speeds [12].Lamentably, the study made no mention of the spatial patterns assumed by these physically-thwarted individuals [12].In an independent previous study [5], changes in spatial patterns and tailbeat frequencies were reported in similar experiments, albeit with no energetic measurements.
Specifically, [5] showed that, when challenged to sustain higher swimming speeds, the fish in a group rearranged themselves in a side-by-side pattern as the speed increased, presumably to save energy.
Taking together the results of [5,12], are we to conclude that side-by-side formations are more energetically beneficial than, say, inline or diagonal formations?The answer is not simple!The metabolic measurements of [4] in a school of eight fish report that side-by-side formations, though beneficial, produce the least energetic savings compared to diagonal formations [1].In an experimental study of a single fish interacting with a robotic flapping foil, the freely-swimming fish positioned itself in an inline formation in the wake of the flapping foil, supporting the hypothesis that swimming in the wake of one another is an advantageous strategy to save energy in a school [11].Why did the fish in the experiments of [5] self-organize in a side-by-side formation when challenged to swim at higher swimming speeds?
The answer is not simple because ample hydrodynamic mechanisms for energy savings in fish schools have been stipulated for each possible configuration -side-by-side, inline and diagonal (see, e.g., Fig. 1 of [12]) -but no assessment is provided of the relative advantage of these configurations.
For example, side-by-side formations, where fish mirror each other by flapping antiphase, are thought to create a wall-like effect that reduces swimming cost [12,29].A fish swimming in the wake between two leading fish encounters a reduced oncoming velocity, leading to reduced drag and thrust production [1].
Inline formations, where fish swim in tandem, are thought to provide benefits to both leader and follower, by an added mass push from follower to leader [29,30] and a reduced pressure on the follower [31].All of these mechanisms can in principle be exploited by schooling fish as they dynamically change their relative spacing in the group.But are these mechanisms equally advantageous?Or is there a hierarchy of hydrodynamic benefits depending on the relative position within the school?The literature offers no comparative analysis of the energetic savings afforded by each of these configurations.
The study of [4] is arguably the closest to addressing this question, but, to map the energetic benefits for pairwise configurations, the authors employed statistical averages in a school of eight fish, thus inevitably combining the various hydrodynamic mechanisms at play and cross-polluting the estimated benefits of each configuration.A cleaner analysis in pairs of flapping foils shows that these relative positions -side-by-side, inline, and diagonal -all emerge spontaneously and stably due to flow interactions [28], but provides no method for estimating the energetic requirements of these formations, let alone comparing them energetically.Even vortex phase matching makes no distinction between sideby-side, inline, or diagonal pairs of fish [9].It simply postulates that an unknown amount of energetic benefit is acquired when the linear phase-distance relationship is satisfied.Thus, to date, despite the widespread notion that group movement saves energy, a direct comparison of the energetic savings afforded by different spatial formations remains lacking.Importantly, it is unknown whether and how the postulated benefits scale with increasing group size.
Here, to circumvent the challenges of addressing these questions in biological systems, we formulate computational models that capture the salient hydrodynamic features of single and pairs of swimming fish.Namely, we represent each fish as a freely-swimming hydrofoil undergoing pitching oscillations about its leading edge.A single flapping hydrofoil shares many hydrodynamic aspects with its biological counterpart, including an alternating, long-lived pattern of vorticity in its wake [32][33][34][35][36].These similarities have been demonstrated repeatedly, within biologically relevant ranges of flapping parameters [32,37], for different geometries [38][39][40][41], material properties [41][42][43], and flapping kinematics [44][45][46].In this study, we show, based on our own simulations and by conducting a thorough literature survey, that flow interactions, with no sensing and feedback control, lead to emergent formations that preserve the linear phase-distance relationship uncovered independently in live and robotic fish [9,11] and in flapping hydrofoils [26][27][28].This relationship is preserved irrespective of geometry [27,28,47], material properties [26,[48][49][50], and flapping kinematics [51,52].The universality of this relationship serves as strong validation of our models and anchors our subsequent exploration of the opportunities for hydrodynamic benefits available in a given flow field.
Importantly, we go beyond two swimmers to investigate flow interactions in larger groups and find that inline formations differentially distribute hydrodynamic savings to members within the school, favoring trailing swimmers, but only up to a certain school size, while side-by-side formations equally distribute hydrodynamic savings and scale to arbitrary number of swimmers without loss of cohesion.Our findings provide a direct mapping from the school's spatial pattern to the energetic savings experienced by its members.Importantly, our results raise an interesting hypothesis that the dynamic repositioning of members within a fish school could be driven by greed and competition to occupy hydrodynamically advantageous positions and open up opportunities for analyzing the role of flow physics in the evolution of cooperative versus greedy behavior in animal groups.

Mathematical models of flow-coupled flapping swimmers
Inspired by the experiments of [9,27], we study self-organization in the context of flapping swimmers, coupled passively via the fluid medium, with no mechanisms for visual [53][54][55][56][57], flow sensing [58][59][60][61], or feedback control [24,62,63] (Fig. 1).The swimmers are rigid, of finite body length L and mass per unit depth m, and undergo pitching oscillations of identical amplitude A and frequency f in the (x, y)-plane of motion, such that the pitching angle for swimmer j is given by θ j = A sin(2πf t + ϕ j ), j = 1, 2, . . ., N , where N is the total number of swimmers.In pairwise interaction, we set ϕ 1 = 0 and ϕ 2 = −ϕ, with ϕ being the phase lag between the oscillating pair.We fixed the lateral distance ℓ between the swimmers to lie in the range ℓ ∈ [−L, L], and allowed the swimmers to move freely in the x-direction in an unbounded two-dimensional fluid domain of density ρ and viscosity µ.
When unconstrained, the swimmers may drift laterally relative to each other, as illustrated in dipole models [64,65] and high-fidelity simulations of undulating swimmers [62,66].However, this drift occurs at a slower time scale than the swimming motion, and can, in principle, be corrected by separate feedback control mechanisms [67].Here, we focus on the dynamics in the swimming direction.
Hereafter, all parameters are scaled using the body length L as the characteristic length scale, flapping period T = 1/f as the characteristic time scale, and ρL 2 as the characteristic mass per unit depth.Accordingly, velocities are scaled by Lf , forces by ρf 2 L 3 , moments by ρf 2 L 4 , and power by The equations governing the free motion x j (t) of swimmer j are given by Newton's second law (here, the downstream direction is positive), The hydrodynamic forces on swimmer j are decomposed into a pressure force F j acting in the direction normal to the swimmer and a viscous drag force D j acting tangentially to the swimmer.These forces depend on the fluid motion, which, in turn, depends on the time history of the states of the swimmers.
To maintain their pitching motions, swimmers exert an active moment M a about the leading edge, whose value is obtained from the balance of angular momentum.The hydrodynamic power P expended by a flapping swimmer is given by P = M a θ.
To emulate the effect of viscosity in the VS model, we allowed shed vorticity to decay after a dissipation time τ diss ; larger τ diss correlates with larger Reynolds number Re in the Navier-Stokes model; see SI for a brief overview of the numerical implementation and validation of both methods.

Flow coupling leads to stable emergent formations
We found, in both CFD and VS models, that pairs of swimmers self-organize into relative equilibria at a streamwise separation distance d that is constant on average, and swim together as a single formation at an average free-swimming speed U (Figs. 1 and 2).We distinguished four types of relative equilibria: inline, diagonal, side-by-side inphase and side-by-side antiphase (Fig. 1).
Inline formations at ℓ = 0 arise when the follower positions itself, depending on its initial distance from the leader, at one of many inline equilibria, each with its own basin of attraction (Fig. 2A).These inline equilibria occur at average spacing d that is approximately an integer multiple of U T , consistent with previous experimental [27,47,75] and numerical [26, 49-51, 76, 77] findings.
When offsetting the swimmers laterally at ℓ ̸ = 0 (Fig. 2B), the leader-follower equilibria that arise at ℓ = 0 shift slightly but persist, giving rise to diagonal leader-follower equilibria [28].Importantly, at a lateral offset ℓ, inphase swimmers (ϕ = 0) that are initially placed side-by-side reach a relative equilibrium where they travel together at a close, but non-zero, average spacing d ≤ L. That is, a perfect side-by-side configuration of inphase flapping swimmers is unstable but the more commonlyobserved configuration [9] where the two swimmers are slightly shifted relative to each other is stable.
This configuration is fundamentally distinct in terms of cost of transport from the mirror-symmetric side-by-side configuration that arises when flapping antiphase at ϕ = π (Fig. 3A).Both side-by-side equilibria were observed experimentally in heaving hydrofoils [28], albeit with no assessment of the associated hydrodynamic power and cost of transport.
We next examined the effect of varying the phase ϕ on the emergent traveling formations.Starting from initial conditions so as to settle on the first equilibrium d/U T ≈ 1 when ϕ = 0, and increasing ϕ, we found, in both CFD and VS simulations, that the spacing d/U T at equilibrium increased with increasing ϕ (Fig. 2C).This increase is linear, as evident when plotting d/U T as a function of ϕ (Fig. 3B).Indeed, in Fig. 3B, we plotted the emergent average separation distance d/U T as a function of ϕ for various values of ℓ.Except for the antiphase side-by-side formation, the linear phase-distance relationship The key observation, that pairs of flapping swimmers passively self-organize into equilibrium formations, is independent of both scale and fluid model.In our CFD simulations (Fig. 1.S1 and 1.S3), we tested a range of Reynolds number Re = ρU L/µ from 200 to 2000, which covers the entire range of existing CFD simulations [50,75], where Re ∼ O(10 2 ), and experiments [27,28,75], where Re ∼ O( 103 ).In our VS simulations, we varied τ diss from 2.45T to ∞ (Figs.1.S2 and 1.S3).Note that the separation distance d is scale-specific and increases with Re; at low Re, a compact inline formation is reached where the two swimmers "tailgate" each other, as observed in [49].However, the scaled separation distance d/U T remains nearly constant for all Re and τ diss (Fig. 1.S3).
The fact that these equilibria emerge in time-forward simulations is indicative of stability [78].A more quantitative measure of linear stability can be obtained numerically by perturbing each equilibrium, either by applying a small impulsive or step force after steady state is reached [28] or by directly applying a small perturbation to the relative equilibrium distance between the two swimmers and examining the time evolution of d and F to quantify variations in hydrodynamic force δF as a function of signed variations in distance δd from the equilibrium [51].In either case, we found that the force-displacement response to small perturbations at each equilibrium exhibited the basic features of a linear spring-mass system, where δF/δd is negative, indicating that the hydrodynamic force acts locally as a restoring spring force that causes the initial perturbation to decay and that stabilizes the two swimmers together at their equilibrium relative position.Larger values of |δF/δd| imply faster linear convergence to the stable equilibrium and thus stronger cohesion of the pairwise formation.Results of this quantitative stability analysis are discussed in subsequent sections.

Emergent formations save energy compared to solitary swimming
We evaluated the hydrodynamic advantages associated with these emergent formations by computing the hydrodynamic power P single of a solitary swimmer and P j of swimmer j in a formation of N swimmers.
We calculated the cost of transport COT j = P j /mU , of swimmer j and the change in COT compared to solitary swimming ∆COT j = (COT single − COT j )/COT single (Fig. 3A).We also calculated the average change in cost of transport ∆COT = N j ∆COT j /N for each formation (Fig. 3B).In all cases, except for the antiphase side-by-side formation, in both CFD and VS simulations, the swimmers traveling in equilibrium formations save power and cost of transport compared to solitary swimming.The savings are larger at tighter lateral spacing ℓ.
For inline and diagonal formations, these hydrodynamic benefits are granted entirely to the follower, whose hydrodynamic savings can be as high as 60% compared to solitary swimming (Fig. 3A) [51].Intuitively, because in 2D flows, vortex-induced forces decay with the inverse of the square of the distance from the vortex location, flow coupling between the two inline or diagonal swimmers is non-reciprocal; the follower positioned in or close to the leader's wake interacts more strongly with that wake than the leader interaction with the follower's wake (Figs.1A, B and 1.S4A, B).
In side-by-side formations, by symmetry, flow coupling between the two swimmers is reciprocal, or nearly reciprocal in inphase flapping (Figs.1C, D and 1.S4C, D).Thus, hydrodynamics benefits or costs are expected to be distributed equally between the two swimmers.Indeed, for inphase flapping, the hydrodynamic benefits are shared equally between both swimmers.For antiphase flapping the cost is also shared equally (Fig. 3A).
The biased distribution of benefits in favor of the follower in inline and diagonal formations could be a contributing factor to the dynamic nature of fish schools [3,6].The egalitarian distribution of benefits in the inphase side-by-side formation could explain the abundance of this pairwise configuration in natural fish populations [9] and why groups of fish favor this configuration when challenged to swim at higher speeds [5,57].
All data collapsed onto the linear phase-distance relationship ϕ/2π ∝ d/U T , with the largest variability exhibited by live fish with close streamwise distance, where the interaction between fish bodies may play a role.The side-by-side inphase formations trivially satisfy this linearity because d/U T ≈ ϕ/2π = 0, but the side-by-side antiphase formations don't satisfy; in the latter, d/U T = 0 while ϕ/2π = 1.
These findings strongly indicate that flow-coupled flapping swimmers passively organize into stable traveling equilibrium formations with linear phase-distance relationship.This relationship is independent of the geometric layout (inline versus laterally-offset swimmers), flapping kinematics (heaving versus pitching), material properties (rigid versus flexible), tank geometry (rotational versus translational), fidelity of the fluid model (CFD versus VS versus particle model), and system (biological versus robotic, 2D versus 3D).Observations that are robust across such a broad range of systems are expected to have common physical and mechanistic roots that transcend the particular set-up or system realization.
Importantly, this universal relationship indicates that flow physics passively positions a swimmer at locations d where the swimmer's flapping phase ϕ matches the local phase of the wake ϕ wake = 2πd/U T , such that the effective phase ϕ eff = ϕ − ϕ wake is zero.Importantly, because the quantity U T is nearly equal to the wavelength of the wake of a solitary swimmer, the phase ϕ wake = 2πd/U T is practically equal to the phase of a solitary leader.These observations have two major implications.First, they are consistent with the vortex phase matching introduced in [9] as a strategy by which fish maximize hydrodynamic benefits.However, they proffer that vortex phase matching is an outcome of passive flow interactions among flapping swimmers, and not necessarily an active strategy implemented by fish via sensing and feedback mechanisms.Second, they led us to hypothesize that emergent side-by-side formations can be predicted from symmetry arguments, while emergent inline and diagonal formations can be predicted entirely from kinematic considerations of the leader's wake without considering two-way flow coupling between the two swimmers.

Leader's wake unveils opportunities for stable emergent formations
To challenge our hypothesis that the leader's wake contains information about the emergent pairwise equilibria, we examined the wake of a solitary swimmer in CFD and VS simulations (Fig. 4A, B).By analyzing the wake of a solitary swimmer, without consideration of two-way coupling with a trailing swimmer, we aimed to assess the opportunities available in that wake for a potential swimmer, undergoing flapping motions, to position itself passively in the oncoming wake and extract hydrodynamic benefit.
Therefore, in the following analysis, we treated the potential swimmer as a "virtual" particle located at a point (x, y) in the oncoming wake and undergoing prescribed transverse oscillations A sin(2πf t − ϕ) in the y-direction, at velocity v(t; ϕ) = 2πAf cos(2πf t − ϕ)e y , where e y is a unit vector in the y-direction.
The oncoming wake is blind to the existence of the virtual particle.Guided by our previous findings that stable equilibrium formations in pairwise interactions occur at zero effective phase ϕ eff = ϕ − ϕ wake = 0, where the net hydrodynamic force on the trailing swimmer is zero and where small perturbations lead to negative force gradients, we introduced two assessment tools: a flow agreement parameter field V(x, y; ϕ) that measures the degree of alignment, or matching, between the flapping motion of the virtual particle and the transverse flow of the oncoming wake, and a thrust parameter field T(x, y; ϕ) that estimates the potential thrust force required to undergo such flapping motions.
Specifically, inspired by [50] and following [51], we defined the flow agreement parameter V(x, y; ϕ) In Fig. 4A and B, we show V(x, y; ϕ = 0) as a field over the physical space (x, y) for ϕ = 0. Blue regions indicate where the local flow favors the follower's flapping motion.In both CFD and VS simulations, the locations with the maximum flow agreement parameter closely coincide with the stable equilibria (black circles) obtained from solving pairwise interactions.These findings imply that hydrodynamic coupling in pairs of flapping swimmers is primarily non-reciprocal -captured solely by consideration of the effects of the leader's wake on the follower.This non-reciprocity allows one, in principle, to efficiently and quickly identify opportunities for hydrodynamic benefits in the leader's wake, without the need to perform costly two-way coupled simulations and experiments.
Importantly, our findings suggest a simple rule for identifying the locations of stable equilibria in any oncoming wake from considerations of the flow field of the wake itself: a potential swimmer undergoing a flapping motion at phase ϕ tends to position itself at locations (x * , y * ) of maximum flow agreement V(x, y; ϕ) between its flapping motion and the oncoming wake.
To verify this proposition, we show in Fig. 5A, as a function of phase ϕ, the streamwise locations of the local maxima of V(x, y; ϕ) computed based on the CFD and VS models, and scaled by U T , where U is the speed of the solitary swimmer.We superimpose onto these results the equilibrium configurations obtained from pairwise interactions in the context of the CFD (♦), VS (■), and time-delay particle (⃝) models, where we modified the latter to account for non-zero lateral offset ℓ (Sec.S.3 and Fig. 5.S1).
Predictions of the equilibrium configurations based on maximal flow agreement parameter agree remarkably well with actual equilibria based on pairwise interactions, and they all follow the universal linear phase-distance relationship shown in Fig. 2B.
The wake of a solitary swimmer contains additional information that allows us to evaluate the relative power savings of a potential follower and relative stability of the pairwise formation directly from the leader's wake, without accounting for pairwise interactions.Assessment of the relative power savings follows directly from the maximal value of the flow agreement parameter: larger values imply more power savings and reduced cost of transport.To verify this, we calculated the maximal V(x * , y * ; ϕ) in the wake of the solitary swimmer, where we expected the follower to position itself in pairwise interactions.In Next, to assess the stability of the virtual particle based only on information in the oncoming wake of a solitary swimmer, we estimated the thrust force based on the fact that the thrust magnitude scales with the square of the swimmer's lateral velocity relative to the surrounding fluid's velocity [27,32,79].We defined the thrust parameter field T(x, y; ϕ) = − 1 |v.e y | 2 dt ′ .At the locations of the maxima of V(x * , y * ; ϕ), a negative slope ∂T/∂d of the thrust parameter is an indicator of linear stability or cohesion of the potential equilibria; that is, emergent pairwise formations are expected to be stable if a small perturbation in distance about the locations (x * , y * ) of maximal V is accompanied by an opposite, restorative change in T. Indeed, in both CFD and VS wakes, ∂T/∂d at (x * , y * ) is negative (Fig. 4).
In Fig. 5C, we plotted |∂T/∂d| as a function of lateral distance ℓ for ϕ = 0. We superimposed the magnitude of the eigenvalues |δF/δd| obtained from the linear stability analysis of pairwise interactions in inphase swimmers using the VS and time-delay particle models.As in Fig. 5B, all quantities are normalized by the maximal value of the corresponding model to highlight variations in these quantities as opposed to absolute values.Also, as in Fig. 5B, all models produce consistent results: pairwise cohesion is strongest for ℓ < 0.25L, but weakens sharply as ℓ increases, with the most pronounced drop in the CFD-based simulations.
A few comments on our virtual particle model and diagnostic tools in terms of the flow agreement and thrust parameters are in order.Our model differs from the minimal particle model used in [27,75], which treated both swimmers as particles with minimal 'wakes' and considered two-way coupling between them (see Sec. S.3).In our analysis, the oncoming wake can be described to any desired degree of fidelity of the fluid model, including using experimentally constructed flows when available.
Indeed, our flow agreement and thrust parameters are agnostic to how the flow field of the oncoming wake is constructed.Additionally, these diagnostic tools are equally applicable to any oncoming wake, not necessarily produced by a single swimmer, but say by multiple swimmers (as discussed later) or even non-swimming flow sources.Thus, the approach we developed here could be applied broadly to analyze, predict, and test opportunities for schooling and hydrodynamic benefits for live and robotic fish whenever measurements of an oncoming flow field are available.

Parametric analysis over the entire space of phase lags and lateral offsets
Having demonstrated consistency in the emergence of flow-mediated equilibria in both CFD and VS simulations, we next exploited the computational efficiency of the VS model to systematically investigate emergent pairwise formations over the entire space of phase lag ϕ ∈ [0, 2π) and lateral offset ℓ excluding side-by-side antiphase formations.
Equilibrium configurations are dense over the entire range of parameters: for any combination of phase lag ϕ and lateral offset ℓ, there exists an emergent equilibrium configuration where the pair of swimmers travel together at a separation distance d/U T (Fig. 6A).Perturbing one or both parameters, beyond the limits of linear stability, causes the swimmers to stably and smoothly transition to another equilibrium at different spacing d/U T .Importantly, increasing the phase lag ϕ shifts the equilibrium positions in the streamwise direction such that d/U T depends linearly on ϕ, but the effect of lateral distance for ℓ ≤ L is nonlinear and nearly negligible for small ℓ: increasing the lateral offset ℓ by an entire bodylength L changes the pairwise distance d/U T by about 15%.Our results explored emergent equilibria up to d/U T ≤ 2.5 and are consistent with the experimental findings in [28], which explored up to nine downstream equilibria.
To assess the hydrodynamic advantages of these emergent formations, we calculated the average change in hydrodynamic power per swimmer.The pair saves power compared to solitary swimming (Fig. 6B).Power savings vary depending on phase lag ϕ and lateral distance ℓ: for the entire range of ϕ from 0 to 2π, the school consistently achieves over 20% power reduction, as long as the lateral offset is ℓ ≤ 0.25L.However, increasing ℓ from 0.25L to L reduces significantly the hydrodynamic benefit.That is, swimmers can take great liberty in changing their phase without compromising much the average energy savings of the school, as long as they maintain close lateral distance to their neighbor.
A calculation of the linear stability of each equilibrium in Fig. 6A shows that these emergent formations are linearly stable (Fig. 6C), and the degree of stability is largely insensitive to phase lag, with strongest cohesion achieved at lateral offset ℓ ≤ 0.25L.The results in Fig. 6A-C are constructed using pairwise interactions in VS simulations, but can be inferred directly from the wake of a solitary leader, as discussed in the previous section and shown in Fig. 6D-F.

Analysis of larger groups of inline and side-by-side swimmers
How do these insights scale to larger groups?To address this question, we systematically increased the number of swimmers and computed the emergent behavior in larger groups based on flow-coupled VS simulations.
In a group of six swimmers, all free to move in the streamwise x-direction, we found that the last three swimmers split and form a separate subgroup (Fig. 7A).In each subgroup, swimmer 3 experiences the largest hydrodynamic advantage (up to 120% power saving!), swimmer 2 receives benefits comparable to those it received in pairwise formation (65% power saving), and swimmer 1 no benefit at all (Fig. 7C).
We asked if loss of cohesion is dependent on the number of inline swimmers.To address this question, we gradually increased the number of swimmers from two to six (Fig. 7.S1).We found that in a school of three inline swimmers, flow interactions led to a stable emergent formation with hydrodynamic benefits similar to those experienced by the three swimmers in each subgroup of Fig. 7A and C. When computing the motion of four inline swimmers (Fig. 8A), we found that the leading three swimmers maintained cohesion, at hydrodynamic benefits similar to a formation of three, but swimmer 4 separated and lagged behind, receiving no advantage in terms of power savings because it split from the formation (Figs. 8D and 7.S1).In a group of five, the last two swimmers split and formed their own subgroup.That is, in all examples, swimmer 4 consistently lost hydrodynamic advantage and served as local leader of the trailing subgroup.These observations are consistent with [49] and demonstrate that flow interactions alone are insufficient to maintain inline formations as the group size increases.
We next explored the robustness of the side-by-side pattern to larger number of swimmers starting from side-by-side initial conditions (Fig. 7B).The swimmers reached stable side-by-side formations reminiscent of the configurations observed experimentally when fish were challenged to swim at higher swimming speeds [5].The swimmers in this configuration saved power compared to solitary swimming (Fig. 7C): swimmers gained equally in terms of hydrodynamic advantage (up to 55% power saving for the middle swimmers in a school of six), except the two edge swimmers which benefited less.We tested these results by gradually increasing the number of swimmers from two to six (Fig. 7.S2).The robustness and overall trend of power saving among group members is robust to the total number of swimmers in these side-by-side formations.

Mechanisms leading to loss of cohesion in larger inline formations
To understand why three swimmers form a stable inline formation but four don't, we extended the analysis in Fig. 4 to analyze the wake created behind two-swimmer (Fig. 9A) and three-swimmer (Fig. 9B) groups.
Specifically, we computed pairwise interactions in a two-swimmer school and considered the combined wake of both swimmers after they had settled onto an equilibrium state.Similarly, we computed the behavior of a three-swimmer school and analyzed the combined wake at steady state.Compared to the single leader wake in Fig. 4B, in the wake of a two-swimmer school, positive flow agreement in the (blue) region is enlarged and enhanced, corresponding to swimmer 3 receiving the largest power savings.On the other hand, behind three inline swimmers, the region of positive flow agreement is weakened and shrunk, indicating weaker potential for energy saving by a fourth swimmer.
Importantly, in the wake of the pairwise formation, the downstream jet is modest at the location of maximum V, where swimmer 3 is expected to position itself for hydrodynamic benefit, thus allowing swimmer 3 to reach this position and stay in formation (Fig. 9E).Also, at this location, the wake has a substantial transverse velocity u • e y (Fig. 9G), which aids thrust production at a diminished cost.In contrast, three inline swimmers generate a much stronger downstream jet at the location of maximum V where swimmer 4 is expected to position itself (Fig. 9F).This jet prevents swimmer 4 from stably staying in formation, and the transverse flow velocity u • e y is nearly zero for the entire flapping period (Fig. 9H) indicating little opportunity for exploiting the flow generated by the three upstream swimmers for thrust generation.This limitation is fundamental; it results from the flow physics that govern the wake generated by the upstream swimmers.There is not much that a trailing swimmer can do to extract hydrodynamic benefits from an oncoming flow field that does not offer any.

Critical size of inline formations beyond which cohesion is lost
We sought to understand what determines the critical group size, here three, beyond which inline formations lose cohesion and split into subgroups.Because we have established that the flow agreement parameter V plays an important role in predicting emergent formations, we first examined V in the wake of a pair of flapping swimmers in CFD (Fig. 1.S1) and VS (Fig. 1.S2) simulations.These results show that at lower Re and smaller dissipation time τ diss , the flow agreement parameter V decays rapidly downstream of the flapping swimmers, thus diminishing the opportunities for downstream swimmers to passively stay in cohesive formation and achieve hydrodynamic benefits.We thus hypothesized that the number of swimmers that passively maintain a cohesive inline formation is not a universal property of the flow physics, but depends on the flow regime.
We tested this hypothesis in VS simulations with increasing number of swimmers and increasing τ diss .As we increased τ diss , the number of swimmers that stayed in cohesive inline formation increased (Fig. 8B,C).These findings confirm that this aspect of schooling -the maximal number of swimmers that passively maintain a cohesive inline formation -is indeed scale-dependent.Interestingly, an analysis of the power savings in these formations shows that, although swimmers 4 and 5 stay in formation at increased τ diss , swimmer 3 always receives the most hydrodynamic benefit (Fig. 8D).
We additionally tested the stability of inline formations in CFD simulations at Re = 1645 (Fig. 9.S1) and observed the same trend: an inline school of 3 swimmers remains cohesive, but a fourth swimmer collides with the upstream swimmer.These observations imply that the loss of cohesion does not depend on the specific fluid model.This is consistent qualitatively with existing results [49].In [49], the authors employed flexible heaving foils at Re = 200 and observed stable inline formations with larger number of swimmers.The flexible foil model and smaller Re make the swimmer more adaptive to changes in the flow field, by passively modulating the amplitude and phase along its body, thus diverting some of the hydrodynamic energy into elastic energy and stabilizing the larger inline formation.This, again, emphasizes that the number of swimmers in a stable inline group is not a universal property of the formation, rather it is model and scale-dependent.

Mapping emergent spatial patterns to energetic benefits
We next returned to the school of four swimmers, which, when positioned inline and flapped inphase, lost cohesion as the trailing swimmer separated from the school.We aimed to investigate strategies for stabilizing the emergent school formation and mapping the location of each member in the school to the potential benefit or cost it experiences compared to solitary swimming.
Inspired by vortex phase matching as an active strategy for schooling [9,24], we tested whether phase control is a viable approach to maintain cohesion and gain hydrodynamic benefits.We devised an active feedback control strategy, where the swimmer senses the oncoming transverse flow velocity at its location and adjusts its flapping phase to maximize the agreement V between its flapping motion and the local flow (see S.5 for more details).When applied to swimmer 4 (Fig. 10A), this phase controller led to a stable formation, albeit at no benefit to swimmer 4; in fact, swimmer 4 spent 100% more power compared to solitary swimming, whereas the power savings of swimmers 2 and 3 remained robustly at the same values as in the formation without swimmer 4. The inability of swimmer 4 to extract hydrodynamic benefits from the oncoming flow is due to a fundamental physical limitations, as explained in Fig. 9; by the non-reciprocal nature of flow interactions, changing the phase of the trailing swimmer has little effect on the oncoming flow field generated by the upstream swimmers.If the oncoming wake itself presents no opportunity for hydrodynamic benefit, phase control cannot generate such benefit.
We next investigated whether collaborative phase modulation could aid in maintaining school cohesion by imposing that each swimmer flaps at a phase lag ∆ϕ relative to the swimmer ahead (Fig. 10B,C).
We found a range of values of ∆ϕ at which the school became passively stable, but without providing much hydrodynamic benefit to the trailing swimmer; in fact, at certain ∆ϕ, cohesion came at a hydrodynamic cost to swimmer 4, much like the active phase control strategy.
Lastly, we investigated whether a lateral offset of some of the swimmers could passively stabilize the emergent formation.The choice of which swimmers to displace laterally and by how much is not unique.
For example, pairing any two of the four swimmers side-by-side, say at the leading, middle, or trailing end of the school, led to cohesive formations.The distribution of hydrodynamic cost or benefit varied depending on the spatial pattern of the school and the individual position within the school.Staggering the swimmers in a zigzag pattern also stabilized the school, but did not always allow the trailing swimmer to improve its cost of transport.Staggering the swimmers in a "Diamond" formation stabilized the school and, of all the stable formations we tested, led to the highest savings in cost of transport for the entire school (Fig. 10D).These results are consistent with existing evidence that diamond formations are both stable [64] and energetically optimal [1,77].But unlike individuals in an infinite diamond lattice [1], individuals in a finite diamond formation do not receive equal energetic benefits.
Our findings highlight the versatility and fluidity of the emergent spatial patterns in groups of flapping swimmers and emphasize that energetic benefits vary depending on the position of the individual within the school.Importantly, these findings imply that, although many emergent formations do not globally optimize the savings of the entire school, hydrodynamic interactions within these formations offer individuals numerous opportunities to achieve varying levels of energetic savings [13], potentially creating competition among school members over advantageous positions in the school.

Discussion
We analyzed how passive flow interactions mediate self-organization in groups of flapping swimmers, all heading in the same direction.Our approach relied on a hierarchy of fluid-structure interaction models and aimed to distill which aspects of self-organization are universal and those which are scaledependent.
We found that a pair of flapping swimmers self-organize into inline, diagonal, or side-by-side formations (Fig. 1).The emergent formation depends on the swimmers' flapping phase and initial conditions.
In fact, the distinction between these types of formation is somewhat arbitrary because, as phase varies, the emergent equilibria are dense over the space of lateral offset and separation distance (Fig. 6).These findings are consistent with experimental observations [9,11,27,28], but go beyond these observations to quantify the hydrodynamic benefits to each member in these formations.Two side-by-side swimmers flapping inphase save energy, compared to solitary swimming, and share the hydrodynamic benefits nearly equally.When flapping antiphase, the side-by-side swimmers exert extra effort compared to solitary swimming, contrary to a common misconception that this configuration saves hydrodynamic energy [12].In leader-follower formations, whether inline or diagonal, hydrodynamic benefits are bestowed entirely on the follower (Fig. 3A).
Importantly, we showed that the wake of a solitary leader contains information that unveils opportunities for the emergence of stable and energetically-favorable formations in pairs of swimmers.Equilibrium locations and trends in power savings and school cohesion can all be predicted entirely from kinematic considerations of the leader's wake with no consideration of the two-way coupling between the two swimmers (Fig. 5).These results are important because they highlight the non-reciprocal or asymmetric nature of flow coupling in leader-follower configuratoins, inline or diagonal, at finite Re and open new avenues for future studies of non-reciprocal flow-coupled oscillators.These oscillators have distinct properties from classic mechanical and biological oscillators, such as Huygens pendula or viscositydominant oscillators, where the coupling between the oscillators is reciprocal; see, e.g., [80][81][82][83][84].
Our analysis has practical importance in that it provides efficient diagnostics and predictive tools that are equally applicable to computational models and experimental data and could, therefore, be applied broadly to analyze, predict, and test opportunities for schooling and hydrodynamic benefits in live and robotic fish when flow measurements are available.
Case in point, we used these diagnostic tools to explain the mechanisms leading to scattering in larger groups of inline swimmers and to predict when the wake of a leading group of swimmers offers no opportunities for a follower to benefit from passive hydrodynamics (Fig. 9).At an increasing number of flow-coupled swimmers, side-by-side formations remain robust, but inline formations become unstable beyond a critical number of swimmers (Figs. 7 and 8).The critical number depends on the fluid properties and can be predicted by analyzing the wake of the leading group of swimmers.Future work will focus on testing these findings experimentally and in CFD simulations with increasing number of swimmers, together with accounting for body deformations [74], lateral dynamics [52,85], and variable flapping amplitudes and frequencies [27,86].
Our findings could have far-reaching consequences on our understanding of biological fish schools.
Field and laboratory experiments [2,4,5,57] have shown that actual fish schools do not generally conform to highly regularized patterns, and schooling fish dynamically change their position in the school.
Neighboring fish vary from side-by-side to inline and diagonal configurations.Importantly, in laboratory experiments that challenged groups of fish to sustain high swimming speeds, the fish rearranged themselves in a side-by-side pattern as the speed increased, much like the pattern in Fig. 7B, presumably to save energy [5].These empirical observations, together with our findings that side-by-side formations provide the fairest distribution of efforts among school members (Fig. 7B and C), offer intriguing interpretations of the results in [5,57]: when the fish are not challenged by a strong background current to sustain high swimming speeds, they position themselves as they please spatially, without much consideration to equal sharing of hydrodynamic benefits.But when challenged to swim at much higher speeds than their average swimming speed, fish are forced to cooperate.
To expand on this, our results suggest a connection between flow physics and what is traditionally thought of as social traits: greed versus cooperation.We posit that there is a connection between the resources that arise from flow physics -in the form of energetic content of the wake of other swimmers -and greedy versus cooperative group behavior.In cohesive inline formations, the leader is always disadvantaged and hydrodynamic benefits are accorded entirely to trailing swimmers (Figs.3A and 7C).
Importantly, flows generated by these inline formations present serious impediments for additional swimmers to join the line downstream (Figs. 7 and 8).Thus, we could call these formations greedy, leaving no resources in the environment for trailing swimmers.This thought, together with our interpretation of the observations in [5] that cooperation to achieve an egalitarian distribution of hydrodynamic benefits is forced, not innate, raise an interesting hypothesis.The dynamic repositioning of members within the school (e.g., Fig. 10) could be driven by greed and competition to occupy hydrodynamically advantageous positions, much like in peloton of racing cyclists [87].On a behavioral time scale, these ideas, besides their relevance to schooling fish, open up opportunities for analyzing and comparing the collective flow physics in cooperative versus greedy behavior in animal groups from formations of swimming ducklings [88] and flying birds [89,90] to peloton of racing cyclists [87].From an evolutionary perspective, it is particularly exciting to explore the prospect that flow physics could have acted as a selective pressure in the evolution of social traits such as cooperation and greed in aquatic animal groups.

B
Lateral y/L Emergent formations in pairs of swimmers in CFD and VS models satisfy a linear phase-distance relationship, consistent with experimental [9,11,27,47,52] and numerical [48][49][50][51] studies.With the exception of the antiphase side-by-side formation, swimmers in these formations have a reduced average cost of transport compared to solitary swimming.and 4.45T , the 4th, 5th and 6th swimmers separate from the group, respectively.D. Power savings per swimmer in panels A-C, respectively.On average, all schools save equally in cost of transport, but the distribution of these savings vary significantly between swimmers.In all case, swimmer 3 receives the most hydrodynamic benefits.A. In an inline school of four-swimmers, the leading three swimmers flap inphase, but swimmer 4 actively controls its phase in response to the flow it perceives locally to match its phase to that of the local flow as proposed in [9].The phase controller stabilizes swimmer 4 in formation but at no hydrodynamic benefit.B. Sequentially increasing the phase lag by a fixed amount ∆ϕ = −30 o in an inline school of four-swimmers stabilizes the trailing swimmer but at no hydrodynamic benefit.C. Gradually tuning the phase lag ∆ϕ in a school of four swimmers as done in panel B. At moderate phase lags, the school stays cohesive (top plot) but swimmer 4 barely gets any power savings (bottom plot).D. By laterally offsetting the swimmers, four swimmers, all flapping inphase, form cohesive schools with different patterns, e.g. with side-by-side pairing of two swimmers, staggered, and diamond patterns.The time evolution of separation distances is shown in Fig. 10.S1.Individual in each pattern receive a different amount of hydrodynamic benefit.Diamond formation provides the most power saving for the school as anticipated in [1] for a school in a regular infinite lattice.In panels A, B and D, % values indicate the additional saving or expenditure in cost of transport relative to solitary swimming.

Fig. 5B ,
Fig.5B, we plotted these V values as a function of lateral distance ℓ for ϕ = 0. We superimposed the power savings ∆P based on pairwise interactions of inphase swimmers using the CFD and VS simulations and normalized all quantities by the maximal value of the corresponding model to highlight variations in these quantities as opposed to absolute values.Power savings are almost constant for ℓ < 0.25L, but decrease sharply as ℓ increases.This trend is consistent across all models, with the most pronounced drop in the CFD-based simulations because the corresponding velocity field u decays more sharply when moving laterally away from the swimmer.

Figure 4 :Figure 5 :
Figure 4: Predictions of equilibrium formations from the wake of a solitary swimmer.A, B. Snapshots of vorticity and fluid velocity fields created by a solitary swimmer in CFD and VS simulations and corresponding flow agreement parameter V fields for a virtual follower at ϕ = 0. Locations of maximum V-values (i.e., peaks in the flow agreement parameter field) coincide with the emergent equilibria in inphase pairwise formations (indicated by black circles).Contour lines represent flow agreement parameter at ±0.25, ±0.5.Thrust parameter T is shown at ℓ = 0 and ℓ = 0.5L.A negative slope ∂T/∂d indicates stability of the predicted equilibria.See also Figs. 1.S1 and 1.S2.

Figure 6 :
Figure 6: Equilibria are dense over the parameter space.For any given phase lag ϕ and at any lateral offset ℓ inside the wake, the pair reach equilibrium formations that are stable and power saving relative to a solitary swimmer.A. Equilibrium separation distances, B. average power saving, and C. stability as a function of phase lag and lateral distance in a pair of swimmers.Predictions of D. equilibrium locations, E. hydrodynamic benefits, and F. cohesion based on the wake of a solitary swimmer following the approach in Figs. 4 and 5.For comparison, the contour lines from panels B and C based on pairwise interactions are superimposed onto panels E and F (white lines).Simulations in panels A-C are based pairwise interactions and Simulations in panels D-F are based on the wake of a single swimmer, all in the context of the vortex sheet model with A = 15 • , f = 1 and τ diss = 2.45T .

Figure 8 :
Figure 8: Loss of cohesion in larger groups of inline swimmers.Number of swimmers that stay in cohesive formation depends on parameter values.A-C.For dissipation time τ diss = 2.45T , 3.45T and 4.45T , the 4th, 5th and 6th swimmers separate from the group, respectively.D. Power savings per swimmer in panels A-C, respectively.On average, all schools save equally in cost of transport, but the distribution of these savings vary significantly between swimmers.In all case, swimmer 3 receives the most hydrodynamic benefits.

Figure 9 :Figure 10 :
Figure 9: Prediction of equilibrium formations, cohesion, and power savings from the wake of upstream swimmers.A., B. Snapshots of vorticity fields created by two inline inphase swimmers, and three inline inphase swimmers.C., D. shows the corresponding flow agreement parameter V fields.Contour lines represent flow agreement parameter at ±0.25, ±0.5.E., F. plots the corresponding periodaveraged streamwise velocity.Separation distances d/U T predicted by the locations of maximal V are marked by circles in the flow agreement field.In the left column, separation distances d/U T based on freely swimming triplets are marked by black circles and coincide with the locations of maximal V.In the right column, the orange marker shows the prediction of the location of a fourth swimmer based on the maximum flow agreement parameter.In two-way coupled simulation, swimmer 4 actually separates from the leading 3 swimmers as illustrated in Fig 8A.CFD simulation shows swimmer 4 will collide with swimmer 3 as in Fig.9.S1.G. , H. shows the transverse flow velocity in a period at the location predicted by the maximum flow agreement parameter and with a lateral offset ℓ = 0, 0.5L, L, in comparison to the follower's tailbeat velocity.