\section{Introduction}\label{sec:intro}
\begin{figure*}
\centering
\includegraphics[scale=1]{./figures/Fig1.eps}
\caption[]{\footnotesize \textbf{Bending rules of swimming fish.} (A) Schematic of flexion parameters in fish with flexion distance $l$, ratio $l/L$ and maximum angle defined as in \cite{Lucas2014}. (B) Flexion ratio $l/L$ and maximum flexion angle $A$  observed in different fish species; data taken from \cite{Lucas2014}. The observed flexion ratio and angles are fairly consistent among different fish species, despite large variations in length scales. 
}
\label{fig:biodata}
\end{figure*}
Millions of years of natural selection endowed fish with remarkable abilities to swim efficiently compared to underwater man-made propulsors~\citep{Sfakiotakis1999,Lauder2005}. 
Several fish use body and caudal fin (BCF) deformations for propulsion. Details of BCF deformations have been used to classify fish swimming modes \citep{Sfakiotakis1999,Shadwick2005,Low2010,Smits2019}. 
Invariably, in most BCF swimming modes, anterior to posterior bending of the fish body seems to play an important role in swimming efficiency, and it is often linked to increased flexibility towards the fish tail or caudal peduncle \citep{Combes2003,Tytell2004,Tytell2010,Tytell2016,Gemmell2016}. 

In an effort to document the bending rules of fluid-based propulsors, both aerial and aquatic, \cite{Lucas2014} collected morphometric data of the flexion parameters across length scales and animal taxa. They identified two parameters to characterize the bending behavior: flexion ratio $l/L$ between the flexion distance $l$ and total length $L$ of the propulsor and maximum flexion angle $A$. They found that flexion ratio and maximum flexion angle of all surveyed animals, including fish, clustered in a limited design space: bending occurs at about $70 \%$ of body length at maximum flexion angle of about $30 ^\circ$, as shown in Figure~\ref{fig:biodata} for swimming fish based on the data collected in \cite{Lucas2014}. 
It is unclear the extent to which this anterior-to-posterior bending is active or whether it follows passively due to the interaction of a flexible posterior with the fluid motion. 
Either way, these findings raise the question of whether hydrodynamics could have provided a selective force for driving this convergent bending design.

To address these questions, we analyze the influence of bending on the swimming speed and efficiency of a simplified fish model that consists of anterior and posterior sections connected via a rotational joint at the flexion point (see Figure~\ref{fig:biodata}A). The fish anterior undergoes  periodic planar pitching while the posterior either (i) moves in synchrony with the anterior as if the two parts were a single rigid body, (ii) bends actively at distinct amplitude and phase relative to the fish anterior, or (iii) bends passively due to interactions with the flow generated by the fish anterior. We find that swimming with passive bending could be more efficient than rigid flapping but at the cost of diminished swimming speed. Active bending provides more possibilities to alter the swimming performance through not only the flexion ratio and maximum flexion angle as reported in~\cite{Lucas2014} but also the phase difference $\phi$ between the flapping motions of the anterior and posterior parts. Importantly, we find that antiphase anterior-to-posterior flexion can simultaneously enhance swimming speed and efficiency in a region of the design parameter space $(l/L, A)$. Flexion ratios and angles that lead to significant improvements in speed and efficiency overlap with the observations of real fish reported in \cite{Lucas2014}. We analyze in depth the hydrodynamic mechanisms underlying these improvements in swimming performance. 

Details of the flow field around swimming fish have received a great deal of attention. 
Several studies used particle image velocimetry to measure the flow field around live fish and analyze the interplay between body deformations and thrust production; see, e.g.,~\cite{Muller1997, Muller2002, Liao2003, Tytell2004, Gemmell2016}. 
In-silico models of various degrees of fidelity to fish morphology and kinematics have also been used to examine the offsets of body deformations on swimming speed and efficiency~\citep{Eldredge2006, Kern2006, Tytell2010, Eloy2013}. 
Importantly, several experimental and numerical studies have shown that plates and foils undergoing pitching or heaving motions provide good approximations of the fluid-structure interactions in swimming fish \citep{Blondeaux2005,Wen2013,Lauder2011,Menon2019}; including the reverse von K{\'a}rm{\'a}n vortex wake left behind swimming fish and flapping foils \citep{Taneda1965,Triantafyllou1993}. 

A variety of fluid-structure interaction models have been proposed to analyze the effect of body flexibility on bending in flows; see, e.g.,~\cite{Shelley2011} and references therein. Here, we present a brief  literature review  focused on this topic.
\cite{Heathcote2007} conducted experiments on a flapper with a rigid leading edge and flexible tail fixed in a water channel and found that flexibility can enhance both efficiency and thrust production. \cite{Eldredge2008} and \cite{Eldredge2010} numerically simulated the flapping motion of articulated rigid links and found that joint flexibility can reduce the power required for flapping.  
\cite{Alben2008} used a filament of uniform flexibility to model the tail of swimming fish in the context of the vortex sheet method and predicted enhancement in efficiency rather than thrust when choosing parameters (dimensionless rigidity and reduced pitching frequency) that are consistent with biological data. 
\cite{Quinn2015} conducted a large set of experiments on two-dimensional pitching and heaving flexible plates at various stiffness values, kinematic parameters, and incoming flow speeds. By combining grid search and gradient-based optimization methods, they found that optimizing the pitching angle with heaving can almost double the propulsor efficiency compared to heave-only motions. 
\cite{Hoover2018} conducted simulations combining three-dimensional Navier-Stokes equation with one-dimensional Euler–Bernoulli beam theory to analyze the motion of heaving flexible plates, and identified local peaks in swimming speed over a parameter space consisting of the beam material property and heaving frequency.
Also using three-dimensional simulations of pitching plates of uniform flexibility, \cite{Dai2012} found that the phase delay $\phi$ between the leading and trailing edge of the plate decreases with increasing stiffness $\kappa$. For large stiffness, the plate moves in no-neck mode (in-phase in our notation), in which thrust production is close to that of a rigid pitching plate with similar trailing edge displacement. 

The effect of uniform flexibility on swimming speed, thrust generation, swimming energetics, and stability have been analyzed in numerous other experimental and computational studies; see, e.g., \cite{Shoele2016,Feilich2015,Michelin2009,Miao2006,Combes2001,Hua2013,Wang2020,Ryu2019}. 
Specifically,~\cite{Liu1997,Heathcote2008,Tangorra2010} have indicated that flexibility could lessen or prevent thrust production.
Flexible propulsors have also been widely used in man-made biomimetic underwater autonomous vehicles (UAV); see, e.g., \cite{Fujiwara2017,Katzschmann2018,Gibouin2018,Zhu2019,White2021}. Most notable is the Tunabot design of  
\cite{Zhu2019} and \cite{White2021} which mimics the shape and bending kinematics of yellowfin tuna (\textit{Thunnus albacares}) and Atlantic mackerel (\textit{Scomber scombrus}). 

While most studies have focused on uniformly flexible bodies, \cite{Combes2003} and \cite{Lucas2014} noted that the stiffness along the fish body is not uniform, but decreases towards the tail, and that the propulsor becomes highly flexible at the flexion point of the body; see Figure~\ref{fig:biodata}(A). 
To explore the effects of non-uniform flexibility on efficiency and thrust production, \cite{Lucas2015} considered flexible plates of inhomogeneous stiffness undergoing heaving and pitching motions in a water tunnel and found that non-uniform stiffness can improve thrust production, and that in order to achieve optimal propulsion, the morphologic factor (flexion ratio) and kinematic factor (motion type and motion parameters) should be considered simultaneously. 
\cite{Vincent2020a,Vincent2020b} analyzed the effect of non-uniform flexibility on flight performance in the context of a tumbling wing model, and found that wing tip flexibility that follows the empirical rules reported in \cite{Lucas2014} leads to improved flight performance.

In this paper, we use a simplified two-link fish model to analyze the influence of active and passive bending on the swimming speed and efficiency. Two link models are commonly used to study the effect of flexibility on the performance of flapping bodies \citep{Eldredge2010, Wan2012,Li2015}. We solve for fluid-structure interactions in the context of the vortex sheet method as described in Section~\ref{sec:formulation}. 
The vortex sheet model has been used extensively to analyze problems of fluid-structure interactions, including ring formation at the edge of a circular tube~\citep{Nitsche1994} and wakes of oscillating plates~\citep{Jones2003,Sheng2012}, falling cards~\citep{Jones2005}, flapping flexible flags~\citep{Alben2008,Alben2009}, swimming plates~\citep{Wu1971}, hovering flyers~\citep{Huang2016, Huang2018} and schooling of swimming plates~\citep{Heydari2020}. 
Here, we use the implementation of \cite{Nitsche1994}. 
In Section~\ref{sec:result1}, we report the effects of both active and passive bending on the swimming performance of sinusoidally pitching swimmers compared to rigid flapping. 
In Section~\ref{sec:con}, we discuss these findings in the context of existing work and highlight the implications of our results on the design of underwater autonomous vehicles.


\section{Problem formulation}\label{sec:formulation}
\begin{figure*}
\centering
\includegraphics[scale=1]{./figures/Fig2.eps}
\caption[]{\footnotesize \textbf{Wake and flow velocity of free swimmers.} (A) Rigid swimmer undergoing periodic pitching (inset) of period $T=1$ and amplitude $a=15^\circ$.  (B,C) Active bending with both anterior and posterior sections undergoing periodic pitching albeit at different amplitude and phase. The anterior follows the same pitching motion (blue line in inset) as the rigid swimmer while the relative rotation of the posterior follows a prescribed Jacobi elliptic sine function (red line in inset) with flexion amplitude $ A = 30 ^ \circ$, flexion ratio $l/L=0.7$, elliptic modulus $M=0.9$, and phase  $\phi= 0$ (in-phase)  and $\phi=\pi$ (antiphase) in B and C, respectively. (D) Passive bending of posterior section while anterior section follows the same prescribed pitching as the rigid swimmer. Joint parameters are set to $\kappa =0$ and $c=1$.
The dissipation time is set to be $T_{\rm{diss}}=1.65T$ in (A-C), $\sqrt{2.09}T$ in (D).}
\label{fig:flowfield}
\end{figure*}

We model the flexible swimmer as a planar two-link body of total length $L$, negligible thickness $e\ll L$, and total mass per unit depth $m=\rho eL$, where $\rho$ is both the swimmer and fluid density, assuming a neutrally-buoyant fish. 
The flexion point indicates where the anterior link (of length $l$) is joined to the posterior link; see Figure~\ref{fig:biodata}(A). 
The anterior link undergoes sinusoidal pitching motion $\theta_a(t) = a\sin(2\pi f t)$, where $\theta_a$ is the angle relative to the swimming direction, taken to be parallel to the $x$-axis. Here, $a$ is the flapping amplitude, $f={2 \pi}/T$ the flapping frequency, and $T$ the flapping period.
When the posterior is connected rigidly to the anterior link at zero flexion, the posterior motion $\theta_p(t)$ is equal to $\theta_a(t)$ and the flexion angle $\alpha = \theta_p - \theta_a$ is identically zero for all time. The two links form a single rigid plate (Figure~\ref{fig:flowfield}A) whose swimming motion due to sinusoidal pitching has been extensively analyzed~\citep{Jones2003,Sheng2012,Moored2019,Heydari2020,Labasse2020}. To explore the effects of body bending on swimming, we consider two cases: (i)  
active bending where the flexion angle $\alpha(t)$ is controlled by the swimmer, and (ii) passive bending where the flexion angle $\alpha(t)$ is dictated by the physics of fluid-structure interactions.

When the two-link swimmer bends actively, we allow the anterior link to have a phase advantage of magnitude $\phi$ relative to the flapping motion of the posterior link. At $\phi = 0$, both anterior and posterior links flap in phase and the swimmer bends in the direction of flapping (Figure~\ref{fig:flowfield}B); for $\phi = \pi$, they flap antiphase resulting in bending in the opposite direction to the anterior pitching motion (Figure~\ref{fig:flowfield}C). The  flexion angle $\alpha(t)$ follows a Jacobi elliptic sine function $\alpha(t)=A \operatorname{sn}(4 K f t, M)$, where $A$ is the maximum flexion angle and $M$ is the elliptic modulus that controls the shape of the elliptic sine function. As $M \to 0$, the elliptic sine function tends to a sinusoidal function and as $M \to 1$, it approaches a square wave shape. The parameter $K$ is introduced to ensure that the flapping frequency of the posterior link is the same as that of the anterior link ($K$ is related to the elliptic modulus $M$ via the elliptic integral and it is given by $K = \mathrm{ellipticF}(\pi / 2, M)$ in Matlab). In this paper, without other specification, we fix $M=0.9$ and explore the effects of the anterior-to-posterior phase difference $\phi$, flexion ratio $l/L$, and maximum flexion angle $A$ on the swimming performance. 

We write the equations governing the self-propelled motion of the two-link swimmer in non-dimensional form. To this end, we  scale all parameter values using $L/2$ as the characteristic length scale, $1/f$ as the characteristic time scale, and $\rho (L/2)^2$ as the characteristic mass per unit depth. Accordingly, velocities are scaled by $Lf/2$, forces by $\rho f^2 (L/2)^3$, moments by $\rho f^2 (L/2)^4$, and power by $\rho f^3 (L/2)^4$. 
The equation of motion governing the free swimming $x(t)$ is given by Newton's second law
\begin{equation}
m \ddot{x}=  F_x - D_x .
\label{eq:eom}
\end{equation}
Here, $F_x$ and $D_x$ denote the components of the hydrodynamic  pressure and drag forces $F$ and $D$ in the swimming direction. Specifically, $F$ is the total force  normal to the swimmer due to hydrodynamic pressure and $D$ is the force tangential to the swimmer due to skin drag. The hydrodynamic pressure force is calculated in the context of the inviscid vortex sheet model~\citep{Nitsche1994, Huang2016, Huang2018, Heydari2020}, and the drag force $D$ is introduced to emulate the effect of fluid viscosity~\citep{Fang2016,Ramananarivo2016}. A brief overview of the vortex sheet method and its numerical implementation is given in Appendix~\ref{app:VSM} and \ref{app:numerics}. Detailed expressions of the fluid forces acting on the swimmer are given in Appendix~\ref{app:forces}. 

When the swimmer bends passively, the relative rotation $\alpha(t)$ of the posterior end is not prescribed a priori and follows from the physics of fluid-structure interactions. Considering that the rotational joint at the flexion point is equipped with a torsional spring of stiffness $\kappa$ and damping coefficient $c$, we write the equation governing the rotational motion of the posterior link
\begin{equation}
I_{p}(\ddot{\theta}_a + \ddot \alpha) +  c \dot{\alpha} + \kappa \alpha =  M_{p} + M_{\rm inertia}, 
\label{eq:eomalpha}
\end{equation}
where $I_{p}$ and $M_p$ are the moment of inertia and hydrodynamic moment acting on the posterior link about the flexion point, $M_{\rm{inertia}}$ is an inertial moment that arises because the flexion point about which the moments are balanced is moving;  see details in Appendix~\ref{app:forces}. 

To assess the swimming performance of the two-link swimmer, we introduce five metrics: the period-average swimming speed $U=\int_t^{t+T}{\dot x dt}$ at steady state, the thrust force $F_x$, the period-average input power $P=\int_t^{t+T}{ P(t) dt}$ required to maintain the prescribed flapping motions, and the propulsion efficiency $mU^2/2PT$ defined as the kinetic energy of the swimmer divided by the input work over one flapping period; see Appendix~\ref{app:forces} for more details. 

\begin{figure*}
\centering
\includegraphics[scale=1]{./figures/Fig4.eps}
\caption[]{\footnotesize \textbf{Active anterior-to-posterior bending of free swimmers.} Time-dependent speed, thrust, input power and circulation for (A) rigid swimmer undergoing pitching at $a=15 ^ \circ$, $T=1$, active flexion (B) at phase difference $ \phi=0$, (C) at phase difference $ \phi=\pi$. In (B) and (C), flexion ratio $l/L=0.7$ and flexion angle $A=30 ^ \circ$. 
Solid lines represent the instantaneous values and dashed lines represent time-period averages. The results are shown after the swimmers have reached steady state $t_{\rm{s}}=15T$. The dissipation time is set to be $T_{\rm{diss}}=1.65T$. 
}
\label{fig:compare}
\end{figure*}
\begin{figure*}
\centering
\includegraphics[scale=1]{./figures/Fig5.eps}
\caption[]{\footnotesize \textbf{Active anterior-to-posterior bending can minimize lateral  forces and negative thrust.} Force hodograph of (A) rigid flapping, (B) in-phase flexion, (C) antiphase flexion for the same cases shown in Figure~\ref{fig:compare}. The arrow indicates the direction of time. The white, blue, red, yellow points are: $t/T= 0$, $0.25$, $0.5$, $0.75$. Bottom row shows force distribution at the instants indicated in red stars. 
Blue arrows represent pitching direction of the anterior link motion while red arrows  of the posterior link.
}
\label{fig:hodograph}
\end{figure*}

\section{Results} \label{sec:result1}
We compare the free swimming that results from flapping while undergoing active and  passive bending to that of rigidly flapping. All swimmers have the same total length $L$ and undergo the same sinusoidal pitching motion about their leading edge $\theta_a = a\sin(2\pi f t)$ with $a= 15^o$ and $f=1$, albeit exhibiting distinct bending patterns. Figure~\ref{fig:flowfield} shows snapshots of the wake represented by the free vortex sheet and velocity field generated by a swimmer undergoing (A) rigid flapping, (B) in-phase active bending with flexion amplitude $A = 30^o$ and flexion ratio $l/L = 0.7$, (C) antiphase active bending at the same flexion amplitude and ratio, and (D) passive bending. All snapshots are taken at the same instant in the flapping cycle (at $0.25T$ after steady state has been reached). 
Compared to the rigid swimmer, in-phase flexion produces wider wakes and larger leading edge circulation and instantaneous flow speeds, while antiphase flexion is characterized by a leaner, longer wake with weaker leading edge circulation and lower flow speeds. 
The main features of the instantaneous flow during antiphase flexion, namely, the leaner wake and weaker leading edge circulation are also observed in passive bending of the swimmer body. These flow features are important for the hydrodynamic forces exerted on the swimmer as discussed later.


\begin{figure*}
\centering
\includegraphics[scale=1]{./figures/Fig6.eps}
\caption[]{\footnotesize \textbf{Active anterior-to-posterior bending of swimmers fixed in oncoming flow.} Time-dependent drag force, input power, and wake circulation for (A) rigid swimmer,  (B) in-phase active flexion ($\phi=0$), (C) antiphase active flexion ($\phi=\pi$). In all cases, the swimmer is fixed in a uniform oncoming flow at $U=9$. 
Results are shown after the swimmers have reached steady state $t_{\rm{s}}=11T$. From top to bottom, drag force, input power and circulation of wake are shown. Solid lines represent the instantaneous values and dashed lines represent time-period averages. The dissipation time is set to be $T_{\rm diss}=1.65T$.  
}
\label{fig:compare2}
\end{figure*}

We quantitatively evaluate the steady state motion of the rigid and actively-bending swimmers in Figure~\ref{fig:flowfield}(A-C). In Figure~\ref{fig:compare}, from top to bottom, we report the instantaneous (solid lines) and period-average (dashed lines) values of the swimming speed, thrust force, input power, and circulation. 
On average, rigid flapping produces the lowest swimming speed while antiphase flexion the highest. Fluctuations around the average swimming speed are smallest for the swimmer undergoing antiphase flexion. 
The discrepancy in average swimming speeds between the three flapping modes is surprising at first sight given that the average values of the thrust force are comparable.  However, a closer look at the instantaneous thrust shows that the swimmer undergoing antiphase flexion hardly experiences negative thrust over its flapping cycle. In-phase flexion leads to negative thrust of high magnitudes over larger subintervals of the flapping cycle, as highlighted further in Figure~\ref{fig:hodograph}.
Consequently, the required input power for in-phase flexion is largest compared to both rigid flapping and antiphase flexion.
This is also true of the overall wake circulation.  It is worth noting that, by Kelvin's circulation theorem, circulation around the leading edge must be equal to the overall circulation in the wake. Therefore, compared to rigid flapping, in-phase flexion increases the circulation around the leading edge of the swimmer while antiphase flexion decreases leading edge circulation as noted qualitatively in Figure~\ref{fig:flowfield}. 

\begin{figure*}
\centering
\includegraphics[scale=1]{./figures/Fig7_v2.eps}
\caption[]{\footnotesize \textbf{Performance of active anterior-to-posterior bending as a function of phase.} 
(A) Free swimmer: swimming speed (black),  power requirement (red), and efficiency (blue) are scaled by the corresponding values of a rigid swimmer.  (B) Swimmer fixed in oncoming flow of uniform speed $U$: drag force (black), power requirement (red) and efficiency (blue) are scaled the corresponding values of a pitching rigid plate fixed oncoming uniform flow. Parameters values are set to $a=15^\circ$, $l/L=0.7$, $A=20^\circ$, $M=0.9$, $U=9$. Flexion agreement parameter $Z$ between the relative velocity of an actively bending posterior and the fluid velocity generated by a passively bending swimmer at zero stiffness $\kappa = 0$ (green) as a function of phase $\phi$ during (A) free swimming  and (B) holding station in oncoming flow $U=5$. 
}
\label{fig:mix}
\end{figure*}

The results in Figure~\ref{fig:compare} indicate that the swimmer undergoing antiphase flexion achieves higher swimming speed at lower power requirement and energetic cost. To elucidate the hydrodynamic forces at play, we report in Figure~\ref{fig:hodograph} the force hodograph defined as a plot of the lateral pressure force $F_y$ versus thrust $F_x$ acting on each swimmer.   
Snapshots of the distribution of hydrodynamic pressure forces along the swimmers are depicted in bottom row of Figure~\ref{fig:hodograph}, and indicate that the $x$-component of the forces on the anterior and posterior sections during antipase flexion act opposite to each other as in a tug-of-war, leading to overall reduction in thrust values. 
Importantly, antiphase flexion also reduces the lateral force and negative thrust, with negative thrust experienced only over a  small subinterval of the flapping period, as noted earlier.
In contrast, in-phase flexion significantly increases the lateral force and negative thrust.

To explain the effect of flexion on the lateral force experienced by the swimmer, it is instructive to re-examine the flow field around the rigid and actively-bending swimmers in Figure~\ref{fig:flowfield}(A-C). 
A large leading edge vortex (LEV) is known to generate large lift in flapping flight; see, e.g.,~\cite{Ellington1984,Dickinson1999}. In swimming, larger leading edge circulation creates larger lateral force, which explains why, compared to rigid flapping, in-phase flexion increases the lateral force acting on the swimmer while antiphase flexion decreases it. 
Lift is beneficial for flight but large lateral forces are detrimental to swimming speed, as noted in~\cite{Drucker2000} for fish and recapitulated here in the context of our swimmer model. 


To further analyze the difference in the swimming performance between rigid flapping and flapping with inphase and antiphase active bending, we fix the swimmer in an oncoming uniform flow of speed $U$  and we compute the hydrodynamic drag forces in each case. In Figure~\ref{fig:compare2}, we report the drag force, input power, and circulation in the wake of the fixed swimmer.
Compared to rigid flapping, antiphase flexion reduces instantaneous drag, power, and circulation, while in-phase flexion increases all three quantities. Reduced drag implies lower thrust requirement during steady state swimming, which provides another perspective for understanding the improved performance of antiphase flexion.  

We next examine the period-average performance of actively bending swimmers as a function of anterior-to-posterior phase difference $\phi$. In Figure~\ref{fig:mix}(A), we consider the case of free swimming, we fix the flexion ratio $l/L=0.7$ and flexion amplitude $A=20^\circ$, and we plot the swimming speed $U$, input power $P$ and efficiency $\eta$ versus $\phi$, all scaled by the corresponding values of a rigidly flapping swimmer $U_{\rm rigid}$, $P_{\rm rigid}$, $\eta_{\rm rigid}$, respectively.
We find that active bending is always beneficial in terms of enhanced speed relative to rigid flapping, albeit at an increased power requirement. Importantly, as the anterior-to-posterior bending changes from in-phase flexion to flexion at a phase lag, the scaled speed increases and the scaled power requirement decreases. Optimal performance occurs at $\phi=0.9$ and $\phi=0.8$ in terms of maximum swimming speed and minimum input power and maximum efficiency, respectively. In Figure~\ref{fig:mix}(B), we fix the swimmer in oncoming flow of uniform speed $U$ and compute the scaled drag force $D$, input power $P$ and efficiency $\eta$ as a function of $\phi$ scaled by the corresponding values of a fixed rigid flapper. 
Analogous to the free swimmer, drag and input power are minimal at $\phi=0.8$. Taken together, the results imply that antiphase active flexion is near optimal for enhancing speed and efficiency and reducing drag force and power requirement.

To complete this analysis, we also explored the effect of the flapping parameter $M$ on the swimming performance. We found that for a fixed phase, the swimming speed and efficiency change monotonically with $M$ with maximum speed and minimum efficiency as $M\to 1$; see Figure~\ref{fig:appendix_M} in the Appendix. That is, reversing the bending direction with a quick flicker improves speed at the cost of decreasing efficiency.

\begin{figure*}
\centering
\includegraphics[scale=1]{./figures/Fig3.eps}
\caption[]{\footnotesize \textbf{Passive anterior-to-posterior bending of free swimmers.} (A) Top to bottom: passive flexion angle $\alpha$ of posterior end at zero stiffness ($\kappa=0$),  moderate stiffness ($\kappa=20$), large stiffness ($\kappa=40$). The anterior link is pitching at $a=15^\circ$. The damping ratio is set to $c=1$, and flexion ratio to $l/L=0.7$. (B) The bending parameters (phase $ \phi$ and maximum flexion angle $A$). (C) Swimming speed $U$ and propulsion efficiency $\eta$ as a function of stiffness $\kappa$ for three flexion ratios $l/L=0.6$, $0.7$, $0.8$ reported in orange, green and black, respectively. The results are shown after the swimmers have reached steady state $t_{\rm{s}}=25T$. The dissipation time is set to be $T_{\rm{diss}}=\sqrt{2.09}T$. 
}
\label{fig:passive}
\end{figure*}

Is active bending necessary for obtaining this enhancement in swimming speed and efficiency over rigid flapping? To address this question, we examine the free swimming of a passively bending swimmer, where the posterior end flaps passively under the effect of hydrodynamic forces and moments generated by the pitching motion of the anterior section. Elastic forces due to a spring of stiffness $\kappa$ located at the flexion point are also at play. In Figure~\ref{fig:passive}(A), we keep all parameter values the same as those used for the actively bending swimmer, and, from top to bottom, we report the flapping motions of the anterior and posterior ends for stiffness values $\kappa=0$, $20$, and $40$. At zero stiffness, flexion introduces no restoring forces and moments. The posterior part rotates antiphase relative to the flapping motion of the anterior part, at an amplitude comparable to the anterior pitching amplitude. The associated wake, shown in Figure~\ref{fig:flowfield}(D) and represented by the free vortex sheet in the inset of Figure~\ref{fig:passive}(A), shares similar features to the wake obtained during antiphase active flexion. At moderate spring stiffness $\kappa=20$, the flexion amplitude increases ($\alpha_{\max} \approx 80^\circ$), and the wake also exhibits larger lateral dispersion. 
At large stiffness $\kappa=40$, the  posterior part rotates in-phase with the anterior part at the same flapping amplitude in a way reminiscent to rigid flapping; as reported in \cite{Dai2012} for flexibble pitching plates. 

The relative motion of the posterior part is close to a sinusoidal function for all stiffness values $\kappa$. Therefore, for each $\kappa$ value, we fit $\alpha(t)$  by a sine function $\alpha(t)=A \sin (\omega t- \phi)$ using a 
standard algorithm~\citep{More1983}. For all fitting, we have at least $95\%$ confidence and frequency $\omega \approx 2\pi$, thus ensuring  convergence of the fitting. In Figure~\ref{fig:passive}(B), we report the fitted flexion amplitude $A$ and phase difference $\phi$ as a function of spring stiffness $\kappa$ for three distinct flexion ratios $l/L =0.6$, $0.7$ and $0.8$. We find that for all $l/L$, as stiffness $\kappa$ increases, the phase difference ${\phi}$ decreases monotonously from $\pi$ to $0$ implying that the posterior flapping motion changes from antiphase to in-phase. The maximum flexion angle ${A}$ first increases with increasing $\kappa$, then decreases to nearly zero at large stiffness implying rigid flapping of both anterior and posterior ends. 

\begin{figure*}
\centering
\includegraphics[scale=1]{./figures/Figure6_vXX.eps}
\caption[]{\footnotesize \textbf{Active bending in agreement with passive hydrodynamics  improves swimming performance.} 
 Illustration of the interaction with the flow field for (A) in-phase and (B) anti-phase active flexion. Maximum improvement in swimming performance occurs when the tail benefits from flows created by the anterior portion of the fish body. 
Light grey arrows represent the flow direction. Red arrows and blue arrows represent the flapping direction of the posterior and anterior sections of the fish body, respectively. 
}
\label{fig:cartoon}
\end{figure*}


We compute the associated swimming speed and efficiency for each stiffness value $\kappa$ and we scale the results by those of a rigid swimmer; see Figure~\ref{fig:passive}(C). Clearly, the swimmer with passive flexion never surpasses the swimming speed of a rigid swimmer. At very low stiffness ($\kappa \approx 0$), passive flexion results in a swimming speed close to that of rigid flapping while doubling the swimming efficiency. The increase in swimming efficiency at small stiffness comes purely from a decrease in power requirement compared to rigid flapping. This is in contrast to active flexion where the enhancement in swimming speed and efficiency noted in Figure~\ref{fig:mix} comes at an increase in power requirement relative to rigid flapping. 
As $\kappa$ increases, the scaled swimming speed  and propulsion efficiency decrease, indicating that moderate flexibility is detrimental to both speed and efficiency. For large $\kappa$, the speed and efficiency converge to the same speed and efficiency as the rigid swimmer, consistent with the results of~\cite{Dai2012}. We repeat this analysis for three flexion ratios $l/L=0.6$, $0.7$, $0.8$. The scaled speed seems to increase monotonically with increasing $l/L$, but the scaled efficiency seems to peak at $l/L = 0.7$ but only for a range of small $\kappa$ values. 
These findings imply that, unlike flapping insect wings~\citep{Ellington1985,Huang2015a}, restoring elastic forces seem to be detrimental to swimming performance. Swimming efficiency peaks at low stiffness values when the restoring spring forces are weak and the posterior end is driven passively by the fluid forces. 
\begin{figure*}
\centering
\includegraphics[scale=1]{./figures/Fig8.eps}
\caption[]{\footnotesize \textbf{Swimming performance of actively flexion swimmer scaled by performance of rigid swimmer.} Average speed and efficiency versus flexion ratio $l/L$ and flexion angle $A$ for (A) in-phase flexion ($\phi=0$) and (B) antiphase flexion ($\phi=\pi$). The amplitude for the proximal part and the elliptic modulus are $a=15^\circ$ and $M=0.9$. Dark grey areas indicate regions of diminished performance while light gray areas indicate improved performance over a rigid swimmer. The dissipation time is set to be $T_{\rm{diss}}=1.65T$. 
}
\label{fig:colormap}
\end{figure*}


Could the swimmer learn from passive flexion to improve its performance by bending actively in a way that exploits the hydrodynamic forces generated naturally during passive flexion? The results in Figures~\ref{fig:flowfield}-\ref{fig:mix} for actively bending swimmers suggest that maximum benefit occurs for near anti-phase flexion, whereas the results in Figure~\ref{fig:passive} show that maximum efficiency for passively bending swimmers occurs for zero stiffness $(\kappa = 0)$ for which the posterior bends anti-phase. Importantly, the main features of the instantaneous flow during antiphase active flexion (Figure~\ref{fig:flowfield}C) are also observed in passive bending at zero stiffness (Figure~\ref{fig:flowfield}D). We thus posit that active bending is most beneficial when the swimmer actively beats its tail in a direction that takes advantage of the natural flows that arise during passive bending.
To test this hypothesis, we define a flexion agreement parameter $Z$ that aims to relate passive and active bending. Starting from a swimmer bending passively at zero spring stiffness $\kappa=0$ (Figures~\ref{fig:flowfield}D and~\ref{fig:passive}A), we assume a hypothetical posterior that is actively flapping about the flexion point of the swimmer at a relative angle  $\alpha = A \sin(2\pi t - \phi)$. We compute the fluid velocity $\mathbf{u}(s,t)$ induced by the passively-bending swimmer along the hypothetical posterior section that is bending actively (here, $s$ is the distance from the flexion point). The flexion agreement parameter $Z$ is given by
\begin{equation}
Z=\frac 1 T \frac 1 {L-l}\int_0^T{\int_0^{L-l}{\mathbf{u}(s,t) \cdot \mathbf{v}(s,t)ds}dt},
\label{eq:flexion_agreement}
\end{equation}
where $\mathbf{v}(s,t) = s \dot{\alpha} \,\mathbf{n}$ is the relative velocity of the hypothetical actively-flapping posterior. Positive values of the flexion agreement parameter imply a beneficial interaction between  the flow generated during passive flexion and the velocity of the hypothesized posterior during active flexion, whereas negative values indicate a detrimental one.


In Figure~\ref{fig:mix}(A), we set $A$ to be equal to the maximum flexion angle of the passively-bending swimmer, and we vary $\phi$ from $0$ to $\pi$. We find that the agreement parameter $Z$, normalized by its maximum value, is largest for antiphase active flexion and smallest near in-phase active flexion.  This result indicates that antiphase active flexion matches the local flow created during passive flexion best, whereas in-phase active flexion acts opposite to these flows. That is, the swimmer during antiphase flexion can utilize better the flow field generated by the pitching motion of its anterior section, and thus it can achieve higher swimming speed and efficiency compared to in-phase flexion.


To emphasize the effect of the interaction between the flow field and kinematics of active flexion on swimming performance,
we schematically summarize the two cases of in-phase and antiphase flexion in Figure~\ref{fig:cartoon}.
During in-phase active flexion, the flow field is characterized by a strong leading edge vortex around the anterior section of the fish and large lateral forces. Further, the posterior part bends opposite to the local flow field of a passively bending swimmer. 
During antiphase active flexion, the leading edge vortex is smaller and it is followed by a counter-rotating vortex around the fish mid-section such that the posterior part is moving in synchrony with the downwash flow induced by this counter-rotating vortex. The flow field is helping the motion of the posterior end. These results indicate that active body deformation that are in agreement with local flows produced during passive deformations are more advantageous for enhancing swimming speeds and efficiencies. 


\begin{figure*}
\centering
\includegraphics[scale=1]{./figures/Fig9_v5.eps}
\caption[]{\footnotesize \textbf{Relation to fish swimming behavior. } 
(A) Comparison of fish flexion parameters (black dots, cite from \cite{Lucas2014}) and regions of optimal performance predicted by our model (anti-phase active flexion swimmer): pink region corresponds to 200\% enhancement in swimming speed, and green region corresponds to 300 \% enhancement in swimming efficiency, both compared to a swimmer of the same total length rigidly flapping with no flexion. Overlap of the two regions is indicated in beige. The contour grey line encloses a region of 600\% enhancement in efficiency. 
}
\label{fig:compareFish}
\end{figure*}


Lastly, we explore the effect of maximum flexion angle $A$ and flexion ratio $l/L$ on the period-average values of the swimming speed and efficiency for both in-phase and antiphase active flexion. Specifically, we examine the range $l/L \in [0.4, 1.0]$ and $A \in [0^\circ, 60^\circ]$ for $\phi = 0$ and $\phi = \pi$.  In Figure~\ref{fig:colormap}, we report the period-average values normalized by the corresponding values for a rigid swimmer with pitching amplitude equal to the anterior part amplitude.
We highlight in light and dark grey respectively the regions in the parameter space where the flexible swimmer outperforms and underperforms the rigid swimmer. The swimmer with in-phase flexion swims slower than the rigid swimmer for small flexion ratios ($l/L < 0.7$) and high flexion amplitudes ($A >40^\circ$), and swims faster than rigid swimmer otherwise. This swimmer, however, is always less efficient than the rigid swimmer for reasons explained previously. In Figure~\ref{fig:colormap}(B), for most parameter values, the antiphase swimmer outperforms the rigid swimmer in terms of swimming speed and efficiency. Note that the region with the highest swimming speed advantage lies in $l/L \in [0.6, 0.8]$ and $ A \in [30^\circ,  60^\circ]$, and the region with the highest efficiency advantage lies in $l/L \in [0.6, 0.8]$ and $ A \in [25^\circ, 50^\circ]$. 


We compare the regions of highest swimming speed and efficiency obtained during antiphase flexion in Figure~\ref{fig:colormap}(B) to the design parameters of biological fish reported in Figure~\ref{fig:biodata}. In Figure~\ref{fig:compareFish}, we plot the flexion angle $A$ as a function of the flexion ratio $l/L$ for the fish data in Figure~\ref{fig:biodata} and we superimpose on this design space the regions of 200\% enhancement in speed and 300\% enhancement in efficiency from Figure~\ref{fig:colormap}(B).
As shown in Figure~\ref{fig:compareFish}, there is significant overlap between these regions of improved performance and the biological data. Indeed, all biological data lie within the region of improved efficiency.


Many of these fish are known to exhibit migratory behavior that requires efficient swimming. Even baby clownfish are reported to migrate over long distances~\citep{Simpson2014}. Tuna can cover $7600$ km  in one traveling phase~\citep{Itoh2003} and tiger shark are capable of traveling long distances in short time~\citep{Simpfendorfer2009}.  Our results in Figure~\ref{fig:compareFish} are consistent with these facts: tiger shark and clownfish lie in the intersection region of improved speed and efficiency, and tuna lies in the region with highest increase in efficiency. On the hand, butterflyfish, who are only known to migrate over short distances during spawning \citep{Yabuta1997}, and Koi, for which there is no evidence of migration, lie in the regions characterized by smaller increase in speed and efficiency.











\section{Conclusion}\label{sec:con}

We analyzed the swimming performance of flapping swimmers undergoing active and passive deformations. Whereas fish exhibit a variety of swimming modes~\cite{Sfakiotakis1999}, we simplified body deformations to account for only anterior-to-posterior bending, with one degree of freedom describing the relative rotation between the two sections. We explored the effects of morphological and kinematic parameters on the swimming speed and efficiency. 

We found that passive body bending, at negligible body stiffness and minor elastic forces, caused anterior-to-posterior antiphase flexion. This antiphase flexion is dictated by the flow physics and causes the swimmer's morphology to get more streamlined compared to rigid flapping with no flexion, thus creating leaner wakes that reduce drag and power requirement and increase efficiency. While drag reduction is desirable for improved efficiency, passive bending also reduced thrust production, thus diminishing swimming speed.  Interestingly, restoring elastic forces at moderate stiffness values seemed detrimental to both swimming speed and efficiency. These findings are consistent with the hypothesis that for maximum efficiency, the fish tail and posterior body should flex like water, exhibiting little or no resistance to the flows generated by the flapping motion of the anterior portion of the body. This hypothesis could explain how anesthetized fish, with no muscle activity, placed in periodic wakes generate oscillatory body deformations that allow the fish to swim upstream~\citep{Beal2006}.


We also found that a swimmer that actively creates antiphase anterior-to-posterior bending enjoyed the same benefits of leaner wake and reduced drag as a passively bending swimmer while mitigating the reduction in thrust and swimming speed.
To quantify the hydrodynamic mechanisms leading to this improved swimming performance, we introduced a flexion agreement parameter that compares the active flexion velocity of the swimmer's posterior to the local flow velocity during passive flexion. We found that during active in-phase flexion, the posterior beats opposite to the local flow that would naturally arise during passive flexion, leading to a negative flexion agreement parameter, and thus lower swimming speed and efficiency. 
During active antiphase flexion, the posterior flaps consistently with the local flow, leading to a positive flexion agreement parameter, and improved speed and efficiency. 

These findings suggest tremendous versatility in swimming performance, even when accounting only for coarse anterior-to-posterior bending motions. They indicate that fish can readily and fluidly transition from efficient (passive bending) to fast (active bending) by actively beating their tail in agreement with the local flow generated during passive bending. 

To explore the role of flow physics on the convergent bending rules of \citep{Lucas2014}, we examined the effect of flexion ratio and maximum flexion angle on the performance of swimmers undergoing active antiphase anterior-to-posterior bending.  We found an optimal region in this design space that simultaneously enhances swimming speed and efficiency. Importantly, we found that this region has a significant overlap with the fish bending parameters reported in \citep{Lucas2014}; see Figure~\ref{fig:cartoon}(A).  In fact, all biological data fell in the region of enhanced efficiency predicted by our model.

Taken together, our results have two major implications on understanding the role of body bending in fish swimming. They are consistent with the hypothesis that fish that actively bend their bodies in a fashion that exploits the local hydrodynamics can at once improve speed and efficiency. They also support the hypothesis that flow physics could have provided a selective force for driving the evolution of fish bending patterns.

Beyond the trade-offs between speed and efficiency explored here, our model could be generalized in future studies to examine transient swimming maneuvers such as turning. \cite{Pollard2019} proposed that a passive posterior not only improves efficiency, but also improves fish maneuverability compared to a rigid body. \cite{Drucker2000} pointed out that although large lateral forces are detrimental to fish swimming speed, they can improve fish maneuverability. Our model predicts large lateral forces during in-phase active flexion, suggesting that this bending pattern, while not optimal for forward swimming, could be beneficial for turning motions. These considerations, as well as models of higher fidelity to the fish biomechanics and fluid environment, will be explored in future research. 

Finally, our finding that active body bending and tailbeat patterns that match local flow velocities that would be produced naturally by anterior sections of the fish body could lead to improved performance and energy savings might have important implications on understanding the mechanisms driving body and caudal fin deformations in swimming~\citep{Ramakrishnan2011,Bozkurttas2007}, schooling~\citep{Heydari2020,Becker2015,Li2020}, and navigating ambient unsteady flows~\citep{Liao2003}. 






