ABSTRACT
Fish detect predators, flow conditions, environments and each other through pressure signals. Lateral line ablation is often performed to understand the role of pressure sensing. In the present study, we propose a non-invasive method for reconstructing the instantaneous pressure field sensed by a fish's lateral line system from two-dimensional particle image velocimetry (PIV) measurements. The method uses a physics-informed neural network (PINN) to predict an optimized solution for the pressure field near and on the fish's body that satisfies both the Navier–Stokes equations and the constraints put forward by the PIV measurements. The method was validated using a direct numerical simulation of a swimming mackerel, Scomber scombrus, and was applied to experimental data of a turning zebrafish, Danio rerio. The results demonstrate that this method is relatively insensitive to the spatio-temporal resolution of the PIV measurements and accurately reconstructs the pressure on the fish's body.
INTRODUCTION
Fish utilize a sensory system, i.e. the lateral line, for detecting the rapidly changing pressure of the flow, and they leverage these pressure signals to sense the surrounding environment (Liao et al., 2003; Ristroph and Zhang, 2008; McHenry et al., 2009; Ashraf et al., 2017; Verma et al., 2018; Halsey et al., 2018; Haehnel-Taguchi et al., 2018; Li et al., 2020, 2022; Ristroph et al., 2015). Ablation of the lateral line is a commonly used method to study its role in a fish's response to external stimuli (Montgomery et al., 1997; Liao, 2006; McHenry et al., 2010; Mekdara et al., 2018, 2021), but the method is highly invasive. To better understand how fish react to unsteady flows, it is necessary to instantaneously intercept the pressure signals received by the fish in a non-invasive manner.
Here, ν is the kinematic viscosity of the fluid. Multi-directional integration schemes utilize the scalar property of pressure, i.e. its local value is independent of the path taken, to improve the accuracy of the pressure estimation. Using this approach, Dabiri et al. (2014) developed an unsteady pressure reconstruction algorithm, known as Queen 2.0, to study animal locomotion (Dabiri et al., 2020; Thandiackal and Lauder, 2020; Costello et al., 2021; Gemmell et al., 2021; Thandiackal et al., 2021; Tack et al., 2021 ;Guo et al., 2022).
However, Queen 2.0 does have its limitations. Firstly, to integrate the pressure gradient, a zero-pressure boundary condition is applied at all external boundaries, which is not always accurate. As demonstrated by He et al. (2020), when, for example, the wake of a turbulent jet crosses one of the boundaries, the pressure reconstruction by Queen 2.0 becomes less accurate. Secondly, Queen 2.0 and most of the direct integration methods do not incorporate information at the fluid–body interface into the pressure reconstruction. This is typically because the velocity measurements, especially those obtained in particle image velocimetry (PIV) experiments, nearest to the body are often unreliable. Thus, to avoid this error from propagating to the pressure estimation, the integration paths are terminated before reaching the fluid–body interface. To then obtain the surface pressure, one would typically have to extrapolate from the nearest neighbor node in the surrounding pressure field. Pirnia et al. (2020) demonstrated that such an approach can provide a very accurate prediction of the surface pressure around stationary objects. However, the error increases greatly when the object is free to deform. They also showed that by incorporating the kinematics of the immersed body into the pressure reconstruction algorithm, the relative error in the surface pressure prediction can be sufficiently reduced.
These results stress the need to have a pressure reconstruction algorithm that: (1) provides the user with the flexibility to alter the applied boundary conditions and (2) incorporates the kinematics of the undulating body into the pressure reconstruction. In recent years, new types of pressure reconstruction algorithms have been developed (Wang et al., 2017; McClure and Yarusevych, 2017; Jeon et al., 2018; Huhn et al., 2016; Cai et al., 2020; Wang et al., 2018; He et al., 2020; Zhang et al., 2020); although these methods have made significant progress in other aspects of pressure reconstruction from velocity measurements, they do not correct the highlighted limitations of Queen 2.0. Furthermore, their applicability to flow fields involving actively deforming bodies remains relatively untested.
Therefore, in this paper, we propose a new method to reconstruct the pressure field around undulating bodies based on physics-informed neural networks (PINNs) (Cai et al., 2022). The most important benefit of using PINNs is their flexibility. PINNs can deal with any boundary condition or no boundary condition, they do not need to deal with the complex grid designs required to incorporate the kinematics of the immersed body, they are less sensitive to the spatio-temporal resolution and noise, and they can patch the results in regions where velocity field data are not available (Cai et al., 2021; Jin et al., 2021; Di Leoni et al., 2022 preprint; Molnar and Grauer, 2022; Du et al., 2023; Molnar et al., 2023; Zhou et al., 2023).
Previous research performed by Raissi et al. (2020) has utilized PINNs to reconstruct the pressure field around a stationary object. To build on this work, we apply the method to reconstruct not only the pressure field around a swimming fish but also the pressure signals sensed by its lateral line.
MATERIALS AND METHODS
Physics-informed neural networks






Here, Ne is the number of data points sampled at each iteration to evaluate the Navier–Stokes residuals. The partial derivatives in the governing equations are computed using automatic differentiation (Baydin et al., 2018), which calculates the derivatives of the outputs (u,v,p) with respect to the network inputs (x,y,t) directly in the computational graph, without any finite differencing methods utilized in more classical computational methods. It is important to stress that the Navier–Stokes residuals can be evaluated at points where measured data are not available, thus providing a means for increasing the resolution of the measured data, which is grounded in physics.
The applied initial and boundary conditions depend on the problem. Because the network is in essence solving the Navier–Stokes equations, the applied initial and boundary conditions can involve either pressure or velocity. Compared with other methods relying on integrating pressure from boundaries to the point of interest, this method does not require a priori knowledge of the boundary conditions and certainly does not enforce the wrong boundary condition when it is not available. Furthermore, PINNs do not rely on a traditional Cartesian grid because they simply take any spatio-temporal coordinate as input and output velocity and pressure. This feature is extremely helpful in dealing with complex animal locomotion problems because the undulating body and the fluids grid do not always coincide with one another. But for PINNs, there is no need to extrapolate from a grid to the body or back. The kinematics of the body can be input as a boundary condition into the network with ease.

To minimize the loss function and optimize the trainable parameters of the network, the ADAM optimizer was used (Kingma and Ba, 2015 preprint). The mini-batch size was set to 10,000. Therefore, at each iteration, a maximum of 10,000 spatio-temporal points were randomly sampled from the entire training dataset to evaluate the terms of the loss functions. The PINN was trained on an NVIDIA a100 graphics card. For each case studied, the network was trained for 1500 epochs, or 1500 passes through the entire dataset, and took approximately 10 h to complete. As shown in the Supplementary Materials and Methods, 1500 epochs sufficiently balances the accuracy of the PINN predictions with the computational cost.
It is important to note that the purpose of the PINN framework is to uncover hidden information from visualizations of the flow field. For this application, the goal is to recover pressure from velocity measurements. Therefore, for every new velocity field, the network must be retrained to obtain the corresponding pressure field. The trained network is not meant to predict the pressure field for a wide range of different flow types, nor is it meant to be used to develop reduced-order models.
In theory, the PINN method can be applied to study undulatory locomotion over a range of Reynolds numbers if the animal's oscillatory motion is primarily 2D and lies in the same plane as the PIV data. To satisfy these two conditions, two datasets of the flow produced by the oscillatory motion of carangiform swimmers were selected. One is the direct numerical simulation (DNS) of a swimming mackerel, which will be used to quantify the accuracy of the method. The other one is an experimental dataset of a turning zebrafish, Danio rerio.
Single fish validation dataset
To test the accuracy of the proposed method, it was applied to a direct numerical simulation of a swimming fish using the ViCar3D, a sharp-interface immersed boundary method (Mittal et al., 2008). The 3D model of the fish is based on the common mackerel (Scomber scombrus). The fish model consists of body and caudal fin, and the caudal fin is modelled as a zero-thickness membrane. A carangiform swimming motion is prescribed by imposing the lateral displacement of the fish body and fin using the following prescription: Δy/L=A(x)sin(kx–2πft+φ); A(x)=a0+a1(x/L)+a2(x/L)2, where Δy is the lateral displacement, L is the body length, x is the axial coordinate along the body starting from the nose, f is the tail beat frequency, φ is a phase and A(x) is the amplitude modulation function. The parameters are set based on literature (Videler and Hess, 1984) to the following values: a0=0.02, a1=–0.08 and a2=0.16. The wave number is set to k=2π/L and the flow Reynolds number based on the body length and tail beat frequency, ReL=L2f/ν, is set to 5000.
In the present simulation, the swimming motion is imposed on a ‘tethered’ fish and a flow velocity is prescribed at the inflow boundary, such that the net force on the fish is nearly zero, thereby simulating self-propelled swimming with net zero acceleration. The fish body and caudal fin are meshed with triangular surface elements and immersed into the Cartesian volume mesh which covers the flow domain. The flow domain size is set to 8L×10L×10L, and this is discretized on a very dense grid with 640×320×240 (approximately 49 million) Cartesian cells. The minimum grid spacing (cell size) is 0.005L and the body length is covered by 200 grid points. The time-step size used in the simulation is Δt=0.001/f, which resolves one tail beat cycle with 1000 time-steps. A no-slip, no-penetration boundary condition is applied on the moving fish body and fin surfaces by using the sharp-interface, immersed boundary method and a zero-gradient velocity boundary condition is applied on the other domain boundaries except the inflow. For the pressure, a zero gradient boundary condition is applied on the fish body as well as all the outer boundaries (Seo and Mittal, 2022).
A 2D slice at a z-plane cutting through the midline of the fish's body was extracted from the 3D velocity field. The 2D velocity and pressure gradients on this plane provide the hydrodynamic signals that a fish would sense with its lateral line. In addition, the simulation results fully define the fish's motion as the velocities at multiple points along the fish's body are known. The data extracted from the simulation results, which contain a time series of velocity fields and defined fish kinematics, were meant to replicate a dataset that can be obtained through experiments. For example, the velocity field on a plane cutting through the midline of a fish's body can be obtained through PIV, and the fish kinematics could be captured by imaging the silhouette of the fish body. The spatio-temporal resolution of the 2D velocity field on this DNS slice was made coarser to replicate data that would be obtained from a PIV experiment with either a large field of view or insufficient resolution.
To test the sensitivity of the proposed method to the spatial resolution, the PINN was trained using velocity fields with a grid size of 0.02L, 0.04L, 0.06L, 0.08L and 0.1L, which would respectively consist of 50, 25, 17, 13 and 10 grid points along the length of the fish's body. For this study, a temporal resolution of 0.02T was used. Here, L is the body length of the fish and T is the time corresponding to the fish's motion, i.e. one period of the tail beating motion. To test the sensitivity of the proposed method to the temporal resolution, the PINN was trained using velocity fields with a time step of 0.02T, 0.04T, 0.06T, 0.08T and 0.1T. For this study, a spatial resolution of 0.02L was used. As previously mentioned, the Navier–Stokes residuals shown in Eqns 8–10 can be evaluated at any points in the domain and not necessarily at points where measurement data are available. Therefore, in the spatio-temporal resolution study, the Navier–Stokes residuals were always evaluated on the finest grid even as the velocity measurements became coarser.



In addition to the resolution of the velocity measurements, it is also expected that the level of noise in the velocity data will affect the accuracy of the PINN's prediction. To test the sensitivity of the proposed method to noise, various levels of artificial white noise were systematically added to the velocity data on the 2D plane extracted from the DNS dataset. The details of this study and its results are available in the Supplementary Materials and Methods.
For each dataset analyzed, the loss function to be minimized consisted of the 2D velocity data loss terms, the residuals of the x and y momentum equations, and the boundary condition loss terms. To incorporate the kinematics of the fish's body, a non-penetration boundary condition was applied on the surface of the fish's body. In addition, a zero-pressure boundary condition was applied at the top and bottom boundaries because they were considerably far away from the fish's motion. An inlet velocity boundary condition was also applied. However, no boundary condition was added to the outlet where the pressure is significantly affected by the wake. Lastly, the divergence free condition was not enforced because a 2D slice was extracted from a 3D velocity field.
For this application, λ1 and λ3 in Eqn 3 were set to 100, λ2 was set to zero and λ4 was set to unity. As shown in Fig. S2, by applying these weights, the PINN can more accurately recover the pressure field and provide a better prediction of the surface pressure. The choice of weights is consistent with that reported by Cai et al. (2021).
Empirical dataset
To test the proposed method on empirical velocity field data, the PINN was used to reconstruct the 2D pressure field around a turning zebrafish, Danio rerio. The velocity fields were obtained from PIV experiments performed by Thandiackal and Lauder (2020).
Before implementing the PINN, the velocity field grid points inside the fish's body were removed from the dataset. Then, the velocity in the direction normal to the zebrafish's body was computed at all time steps. Lastly, because the PINN utilizes the non-dimensional form of the Navier–Stokes equations, the spatio-temporal coordinates and the velocities were non-dimensionalized. The characteristic time was the turning time (0.15 s), the characteristic length was the zebrafish body length (22 mm), and the characteristic velocity was computed by dividing the center of mass displacement by the turning time. The Reynolds number for this case was 918. The dimensionless grid had a spatial resolution of 0.02 and a temporal resolution of 0.03. A total of 36 time-steps were included in the training dataset.
For the empirical dataset, the loss function to be minimized consisted of the 2D velocity data loss terms, the x and y momentum equations, and a loss term needed to enforce a non-penetration boundary condition on the surface of the fish's body. In this case, the zero pressure boundary conditions were not enforced at any of the boundaries because the zebrafish is relatively close to the top and left boundaries at various points throughout its turning motion. It is uncertain whether the pressure field induced by the fish motion would affect the boundaries. When such uncertainty exists, it is better not to enforce the zero-pressure boundary condition; rather, one should allow the PINN to learn what the pressure at the boundaries should be based on all the information provided during the training process. The same weighting factors used for the simulation data were applied in this experimental data as well.
RESULTS AND DISCUSSION
Results for validation dataset
Fig. 1 compares the instantaneous pressure field at t=0.2T obtained from the simulation with that predicted by the PINN and Queen 2.0. The results were computed from the simulation dataset with a spatial resolution of 0.02L and a temporal resolution of 0.02T.
Comparison of the 2D pressure field and surface pressure profiles predicted by the physics-informed neural network (PINN) and Queen 2.0. (A) The 2D dimensionless pressure (Cp) data cut through the mid-plane of the fish from (B) the full 3D direct numerical simulation (DNS) results. (C–F) The reconstructed pressure fields and their associated absolute error for each method. The arrows denote a region where the localized error in the Queen 2.0 prediction is much larger than PINN. (G) The surface pressure profiles, including the DNS results (circles) and the prediction from the PINN (solid) and Queen 2.0 (dashed), on the right (R, blue) and left (L, red) sides of the fish body. (H) The dimensionless pressure difference (ΔCp) between the left and right side of the body predicted by each method. In all panels, L refers to the fish body length.
Comparison of the 2D pressure field and surface pressure profiles predicted by the physics-informed neural network (PINN) and Queen 2.0. (A) The 2D dimensionless pressure (Cp) data cut through the mid-plane of the fish from (B) the full 3D direct numerical simulation (DNS) results. (C–F) The reconstructed pressure fields and their associated absolute error for each method. The arrows denote a region where the localized error in the Queen 2.0 prediction is much larger than PINN. (G) The surface pressure profiles, including the DNS results (circles) and the prediction from the PINN (solid) and Queen 2.0 (dashed), on the right (R, blue) and left (L, red) sides of the fish body. (H) The dimensionless pressure difference (ΔCp) between the left and right side of the body predicted by each method. In all panels, L refers to the fish body length.
The PINN effectively captures the high-pressure region near the head, the large pressure variation near the tail and the pressure fluctuation in the wake. In comparison, Queen 2.0 captures the high-pressure region at the head but is less accurate near the tail. In fact, Queen 2.0 does not capture the negative pressure region on the right side of the fish's tail (indicated by the arrow in Fig. 1A,C,E) and instead predicts a region of positive pressure. This results in localized errors that are much larger than those obtained by the PINN.
The decrease in the errors predicted by the PINN in the tail region can be attributed to the fact that it utilizes the fish's kinematics as another constraint in the pressure reconstruction and resolves the pressure field up to the fluid–body interface, whereas Queen 2.0 does not. Furthermore, Queen 2.0 enforces a zero-pressure boundary condition on the right side of the domain. This is not an accurate boundary condition because the vortices shed by the beating tail pass through the boundary and result in a non-zero pressure. For the Queen 2.0 reconstruction, in the wake region, certain areas exhibit higher errors than others. This is most likely because in these localized regions the multi-directional integration scheme is not able to sufficiently mitigate the error introduced by applying a zero-pressure boundary condition on the right side of the domain. For PINNs, there is no need to enforce this boundary condition and introduce the associated error into the pressure reconstruction. Thus, for the PINN reconstruction, the error in the wake region is more uniform. The results in Fig. 1 demonstrate how the PINN can overcome limitations of Queen 2.0 and provide an accurate reconstruction of the pressure field surrounding a swimming fish.
It is important to note that both algorithms produced an increased error in regions where the out-of-plane velocities are non-negligible (i.e. in the tail and wake region). This is unsurprising, as only the 2D flow field was used during the pressure reconstruction. A more detailed discussion of this result can be found in the Supplementary Materials and Methods.
To better understand the signals that a fish is sensing with its lateral line, the pressure reconstruction method must accurately predict the pressure on the surface of the fish's body. To obtain the surface pressure using Queen 2.0, one must extrapolate from the reconstructed pressure field. As was done in Thandiackal and Lauder (2020), the pressure at a point on the body is typically assumed to be the pressure at the closest grid point. In contrast, the PINN provides the ability to predict the surface pressure directly without any need for extrapolation.
Fig. 1G,H compares the surface pressure on the left (red) and right (blue) side of the fish's body and the pressure difference between the two sides as predicted by the PINN and Queen 2.0 with that obtained from the simulation. The pressure difference profiles are included because Ristroph et al. (2015) have suggested that the pressure difference is a quantity that fish can sense. The results demonstrate that, for most of the sensing region of the fish, both methods can accurately predict the surface pressure, with the PINN being slightly more accurate particularly in the tail region. This can be confirmed quantitatively by computing the relative RMSE in the surface pressure according to Eqn 14. The PINN has a relative error of 10.1%, whereas Queen 2.0 has an error of 12.0% at this time step.
Results for the spatio-temporal resolution study
The benefit of using PINNs becomes more apparent as the spatio-temporal resolution of the velocity field deteriorates. Fig. 2 compares the instantaneous surface pressure at t=0.3T (top row) and t=0.6T (bottom row) on the right side of the fish's body predicted by the simulation with that predicted by the PINN and Queen 2.0 for each spatial and temporal resolution tested. For most of the body, the pressure predictions by the PINN collapse onto the simulation results for each of the spatio-temporal resolutions tested, although at the coarsest resolution tested, comparatively larger deviations can be observed in the tail region. This result indicates that, for most of the body, the accuracy of the pressure reconstructed by the PINN is not that sensitive to the spatio-temporal resolution of the measured velocity field. For Queen 2.0, the accuracy of the surface pressure prediction greatly decreases as the resolution becomes coarser. The coarser the PIV grid, the farther the distance between the fish surface to the nearest PIV grid point. Because Queen 2.0 requires extrapolation from the grid to the surface, a longer extrapolation distance results in a larger error, as expected. The decrease in accuracy as a function of the temporal resolution, in contrast, can most likely be attributed to the fact that the finite difference approximation of the material derivative shown in Eqn 2 becomes less accurate with a larger time step.
Dimensionless surface pressure (Cp) profiles reconstructed from the velocity data using the PINN and Queen 2.0. Profiles were reconstructed at different (A,B) spatial and (C,D) temporal resolutions: 0.02 (red), 0.06 (blue) and 0.1 (green) for two different times. (A–D) Insets show the fish body position at the given time step. (E,F) The relative global root mean square error in the surface pressure prediction obtained by both methods as a function of the (E) spatial and (F) temporal resolution of the particle image velocimetry (PIV) data. In all panels, L refers to the fish body length and T refers to the tail-beat period.
Dimensionless surface pressure (Cp) profiles reconstructed from the velocity data using the PINN and Queen 2.0. Profiles were reconstructed at different (A,B) spatial and (C,D) temporal resolutions: 0.02 (red), 0.06 (blue) and 0.1 (green) for two different times. (A–D) Insets show the fish body position at the given time step. (E,F) The relative global root mean square error in the surface pressure prediction obtained by both methods as a function of the (E) spatial and (F) temporal resolution of the particle image velocimetry (PIV) data. In all panels, L refers to the fish body length and T refers to the tail-beat period.
Fig. 2E,F shows how the relative global RMSE in the surface pressure prediction by each method varies as a function of the spatial and temporal resolution. For Queen 2.0, the error quickly grows as the resolution becomes coarser, but for the PINN the error profile remains relatively flat across all temporal resolutions tested. The error only begins to really rise as the spatial resolution exceeds 0.04L. Note that the errors reported in Fig. 2E,F only represent the global average; the improvement of local pressure prediction could be much larger than these values.
Results for empirical dataset
Fig. 3A–F compares the instantaneous velocity field obtained from the PIV experiments with that reconstructed by the PINN. The PINN can accurately reconstruct the velocity fields, with absolute errors not exceeding 0.1. Because the optimization process was regularized by the Navier–Stokes residuals, an accurate reconstruction of the velocity field would imply that the reconstructed pressure field is also accurate. Fig. 3G,H shows the reconstructed pressure field around a turning zebrafish and the pressure distribution along its body directly predicted by the PINN. Although it is difficult to make a direct comparison to Queen 2.0 because the ground truth pressure field is unknown, the results from the validation case suggest that the PINN prediction would be more accurate because it resolves the pressure field all the way to the body, it incorporates the zebrafish's kinematics into the pressure reconstruction, and does not enforce a zero-pressure boundary condition because the zebrafish's motion may induce flows crossing the boundaries.
Reconstructed velocity and pressure fields for the empirical dataset. (A–F) The predicted velocity fields versus the direct PIV measurements and their differences. (G,H) The instantaneous dimensionless pressure field (Cp) and surface pressure [(Cp)s] predicted by the PINN. Here, U is the free-stream velocity and L refers to the fish body length.
Reconstructed velocity and pressure fields for the empirical dataset. (A–F) The predicted velocity fields versus the direct PIV measurements and their differences. (G,H) The instantaneous dimensionless pressure field (Cp) and surface pressure [(Cp)s] predicted by the PINN. Here, U is the free-stream velocity and L refers to the fish body length.
Comparative advantage
In this paper, a machine learning-based method for reconstructing the 2D pressure field around swimming fish from PIV measurements was developed. PINNs provide the user with greater flexibility in applying boundary conditions and provide a framework for incorporating the kinematics of the body into the pressure reconstruction process without requiring any deforming grids. When compared with Queen 2.0, at the highest resolution of the PIV data, PINNs provide a small improvement in accuracy, but as the resolution decreases, PINNs show a clear advantage with much smaller reconstruction uncertainty. The applicability of PINNs to experimental data with no clear knowledge of the boundary condition was also demonstrated.
Acknowledgements
We thank S. Cai and G. Karniadakis for providing an initial framework of the PINN code, and R. Thandiackal and G. Lauder for providing the PIV data for the turning zebrafish test case. We also thank the Advanced Research Computing at Hopkins (ARCH) core facility (rockfish.jhu.edu) for providing computational support for this work.
Footnotes
Author contributions
Conceptualization: M.A.C., R.N.; Methodology: M.A.C., R.N.; Software: M.A.C.; Validation: M.A.C., R.M., J.-H.S.; Data curation: R.M., J.-H.S.; Writing - original draft: M.A.C.; Writing - review & editing: M.A.C., R.M., J.-H.S., R.N.; Visualization: M.A.C.; Project administration: R.N.; Funding acquisition: R.N.
Funding
This work was supported by the Office of Naval Research [N00014-21-1-2661]. Open access funding provided by Johns Hopkins University. Deposited in PMC for immediate release.
Data availability
The PINN codes can be accessed at https://github.com/JHU-NI-LAB/PINNS_for_undulating_bodies.
References
Competing interests
The authors declare no competing or financial interests.