Temporal Consistency Loss for Physics-Informed Neural Networks
Physics-informed neural networks (PINNs) have been widely used to solve
partial differential equations in a forward and inverse manner using deep
neural networks. However, training these networks can be challenging for
multiscale problems. While statistical methods can be employed to scale the
regression loss on data, it is generally challenging to scale the loss terms
for equations. This paper proposes a method for scaling the mean squared loss
terms in the objective function used to train PINNs. Instead of using automatic
differentiation to calculate the temporal derivative, we use backward Euler
discretization. This provides us with a scaling term for the equations. In this
work, we consider the two and three-dimensional Navier-Stokes equations and
determine the kinematic viscosity using the spatio-temporal data on the
velocity and pressure fields. We first consider numerical datasets to test our
method. We test the sensitivity of our method to the time step size, the number
of timesteps, noise in the data, and spatial resolution. Finally, we use the
velocity field obtained using Particle Image Velocimetry (PIV) experiments to
generate a reference pressure field. We then test our framework using the
velocity and reference pressure field.
Sukirt Thakur, Maziar Raissi, Harsa Mitra, Arezoo Ardekani
# Temporal Consistency Loss for Physics-Informed Neural Networks

###### Abstract

Physics-informed neural networks (PINNs) have been widely used to solve partial differential equations in a forward and inverse manner using deep neural networks. However, training these networks can be challenging for multiscale problems. While statistical methods can be employed to scale the regression loss on data, it is generally challenging to scale the loss terms for equations. This paper proposes a method for scaling the mean squared loss terms in the objective function used to train PINNs. Instead of using automatic differentiation to calculate the temporal derivative, we use backward Euler discretization. This provides us with a scaling term for the equations. In this work, we consider the two and three-dimensional Navier-Stokes equations and determine the kinematic viscosity using the spatio-temporal data on the velocity and pressure fields. We first consider numerical datasets to test our method. We test the sensitivity of our method to the time step size, the number of timesteps, noise in the data, and spatial resolution. Finally, we use the velocity field obtained using Particle Image Velocimetry (PIV) experiments to generate a reference pressure field. We then test our framework using the velocity and reference pressure field.

_Keywords--_ Physics-informed neural networks, Deep learning, Inverse modelling

## 1 Introduction

Physics-informed neural networks [1, 2] (PINNs) have become a popular method for solving a wide range of forward and inverse problems. While traditional deep learning methods are data intensive and do not consider the physics of the problem, PINNs leverage the prior information that we have in the form of governing partial differential equations (PDEs). Using the governing equations to regularize the optimization of parameters in PINNs allows us to train large networks with small datasets. This
proves handy for problems in biological and engineering systems, as collecting data can be tedious and expensive.

Augmentations to PINNs can be made in five dimensions: 1) More complex physics, 2) more complex geometries, 3) better loss functions, 4) better architectures, and 5) better training processes. While PINNs have been used to solve a whole range of multiphysics problems [3, 4, 5], there has been much interest in deploying PINNs to tackle problems in fluid mechanics [6, 7, 8, 9]. PINN-based frameworks have been used to model high-speed aerodynamic flows [10], porous media flows [11], and biomedical flows [12]. Recently, PINNs have been used to solve non-Newtonian and complex fluid systems [13, 14].

While vanilla feed-forward neural networks remain the most popular architecture, PINNs have been extended to use multiple feed-forward networks [15, 16], convolution neural networks [17, 18], recurrent neural networks [19, 20], and Bayesian neural networks [21]. However, there are challenges associated with training PINNs. It is not straightforward to train PINNs with "stiff" PDEs and multiscale problems. There have been numerous efforts to tackle the problem of assigning relative weights to the different objectives. Apart from assigning relative weights through trial and error, the methods include learning rate annealing [22], minmax weighting [23], using the eigenvalues of the neural tangent kernel matrix [24] and using the soft self-attention mechanism [25].

In this work, we focus on a better loss function and training process for PINNs. We leverage the scales we have in the observed data to obtain the relative scales of the loss terms. We use backward Euler discretization for time stepping instead of automatic differentiation for the temporal derivative. Other discrete schemes can be used as well, we focus on backward Euler discretization in this work without any loss of generality. This allows us to use the scale in the observed data to scale the governing equations.

In this work, we consider the two-dimensional and three-dimensional Navier-Stokes equations which govern fluid flows. We obtain the viscosity using the velocity and pressure fields as the observations. We test the sensitivity and robustness of our method to the time step size, the number of timesteps, noise in the data, and spatial resolution for a numerical dataset in section 3.1. Here, the number of timesteps refers to the number of discrete time slices we randomly sample from. As our method works robustly, we benchmark our method against the experimental dataset of Particle Image Velocimetry (PIV) observations in section 3.2. Finally, we provide some concluding remarks and discuss the future scope of our work in section 4.

## 2 Methodology

### Fluid Governing Equations

The conservation of mass for an incompressible fluid is given by

\[\nabla\cdot\mathbf{u}=0, \tag{1}\]

where \(\mathbf{u}\) is the fluid velocity vector. The conservation of momentum of an incompressible Newtonian fluid under isothermal, single-phase, transient conditions in the absence of a body force is given by

\[\left(\frac{\partial\mathbf{u}}{\partial t}+\mathbf{u}\cdot\nabla\mathbf{u}\right)=-\frac {1}{\rho}\nabla p+\nu\nabla^{2}\mathbf{u}, \tag{2}\]
where \(\rho\) is the density of the fluid, \(\mathbf{u}\) is the velocity vector, \(t\) is the time, \(p\) is the pressure, and \(\nu\) is the kinematic viscosity. The vector form of the momentum equation in two dimensions in \(x\) and \(y\) directions is, respectively, given by

\[\begin{split}& u_{t}+uu_{x}+vu_{y}=-\frac{1}{\rho}p_{x}+\nu(u_{xx}+u _{yy}),\\ & v_{t}+uv_{x}+vv_{y}=-\frac{1}{\rho}p_{y}+\nu(v_{xx}+v_{yy}), \end{split} \tag{3}\]

Figure 1: We employ a fully connected neural network with eight hidden layers and 128 neurons per hidden layer to learn the viscosity from velocity and pressure fields in two dimensions. The network takes \(t,x,y\) as inputs and outputs the scalar field \(\psi\) and the pressure \(p\). We employ automatic differentiation to compute the losses described in section 2. Here, \(I\) denotes the identity operator, and we compute the differential operators \(\partial x\) and \(\partial y\) using automatic differentiation.

Figure 2: We employ a fully connected neural network with ten hidden layers and 200 neurons per hidden layer to learn the viscosity from velocity and pressure fields in three dimensions. The network takes \(t,x,y,z\) as inputs and outputs the components of the vector field \(\mathbf{\psi}\) and the pressure \(p\). We employ automatic differentiation to compute the losses described in section 2. Here, \(I\) denotes the identity operator, and we compute the differential operators \(\partial x\) and \(\partial y\) using automatic differentiation.
where the subscripts denote the derivatives. The momentum equation in vector form in the \(x\), \(y\) and \(z\) directions is, respectively, given by

\[u_{t}+uu_{x}+vu_{y}+wu_{z}=-\frac{1}{\rho}p_{x}+\nu(u_{xx}+u_{yy}+ u_{zz}),\] \[v_{t}+uv_{x}+vv_{y}+wv_{z}=-\frac{1}{\rho}p_{y}+\nu(v_{xx}+v_{yy} +v_{zz}), \tag{4}\] \[w_{t}+uw_{x}+vw_{y}+ww_{z}=-\frac{1}{\rho}p_{z}+\nu(w_{xx}+w_{yy} +w_{zz}),\]

### Physics informed neural networks

We define the spatial coordinates in two and three dimensions as \(\mathbf{x}=(x,y)\) and \(\mathbf{x}=(x,y,z).\) We define the velocity field of an incompressible isothermal Newtonian fluid as

\[\mathbf{u}(t,\mathbf{x})=(u(t,\mathbf{x}),v(t,\mathbf{x})), \tag{5}\]

in two dimensions and as

\[\mathbf{u}(t,\mathbf{x})=(u(t,\mathbf{x}),v(t,\mathbf{x}),w(t,\mathbf{x})), \tag{6}\]

in three dimensions. Our observables at the \(N\) spatio-temporal data coordinates \(\{(t_{n},\mathbf{x}_{n}),n=1,\ldots,N\}\) are the corresponding velocity and pressure fields. We define the velocity field in three dimensions as

\[\mathbf{u}=\nabla\times\mathbf{\psi}, \tag{7}\]

where \(\mathbf{\psi}\) is a vector in three dimensions. We define the vector \(\mathbf{\psi}\) with components \(\psi^{1},\psi^{2},\) and \(\psi^{3}\). We get the velocity field as

\[u=\psi^{3}_{y}-\psi^{2}_{z} \tag{8}\] \[v=\psi^{1}_{y}-\psi^{3}_{z}\] \[w=\psi^{2}_{y}-\psi^{1}_{z},\]

where \(u,v\) and \(w\) are the components of velocity in the \(x,y\) and \(z\) directions, respectively. By definition, the velocity field will then satisfy the continuity equation (1). In two dimensions, for the \(x\) and \(y\) components of velocity, we make the assumption that

\[u=\psi_{y},v=-\psi_{x}, \tag{9}\]

for some latent function \(\psi(t,\mathbf{x})\). We approximate the function \((t,x,y)\longmapsto(\psi,p)\) using a deep neural network with parameters \(\theta\) for the two-dimensional case. Here \(p\) denotes the pressure field. For the three-dimensional case, a deep neural network with parameters \(\theta\) was used to approximate the function \((t,x,y,z)\longmapsto(\psi^{1},\psi^{2},\psi^{3},p)\). The schematic for the neural network setup for the two and three-dimensional cases are shown in fig. 1 and 2, respectively. We define the mean squared loss for regression over the velocity and pressure fields in two-dimensions as

\[L_{data}(\theta)= \mathbb{E}_{(t,x,y,u)}[\frac{|u(t,x,y;\theta)-u|^{2}}{{\sigma_{u} }^{2}}]+ \tag{10}\] \[\mathbb{E}_{(t,x,y,v)}[\frac{|v(t,x,y;\theta)-v|^{2}}{{\sigma_{v} }^{2}}]+\] \[\mathbb{E}_{(t,x,y,p)}[\frac{|p(t,x,y;\theta)-p|^{2}}{{\sigma_{p} }^{2}}],\]
and in three-dimensions as

\[\begin{split} L_{data}(\theta)=&\mathbb{E}_{(t,x,y,z,u) }[\frac{|u(t,x,y,z;\theta)-u|^{2}}{{\sigma_{u}}^{2}}]+\\ &\mathbb{E}_{(t,x,y,z,v)}[\frac{|v(t,x,y,z;\theta)-v|^{2}}{{ \sigma_{v}}^{2}}]+\\ &\mathbb{E}_{(t,x,y,z,w)}[\frac{|w(t,x,y,z;\theta)-w|^{2}}{{ \sigma_{w}}^{2}}]+\\ &\mathbb{E}_{(t,x,y,z,p)}[\frac{|p(t,x,y,z;\theta)-p|^{2}}{{ \sigma_{p}}^{2}}],\end{split} \tag{11}\]

where \(\sigma_{u}\), \(\sigma_{v}\) and \(\sigma_{w}\) are the standard deviation of the \(x\), \(y\) and \(z\) components of the reference velocity field, and \(\sigma_{p}\) is the standard deviation of the reference pressure field. Here \(\mathbb{E}\) denotes the expectation approximated by the population mean (i.e., mean of the observations \(t_{n},x_{n},y_{n},z_{n},u_{n},v_{n},w_{n},p_{n},n=1,\ldots,N\).). Now, considering the momentum equation in two-dimensions (3), we define

\[\begin{split}& g(u,v,p;\nu)=uu_{x}+vu_{y}+p_{x}-\nu(u_{xx}+u_{yy}), \\ & h(u,v,p;\nu)=uv_{x}+vv_{y}+p_{y}-\nu(v_{xx}+v_{yy}),\end{split} \tag{12}\]

and for three-dimensional momentum equation (4), we have

\[\begin{split}& l(u,v,w,p;\nu)=uu_{x}+vu_{y}+wu_{z}+p_{x}-\nu(u_{xx}+u_{ yy}+u_{zz}),\\ & m(u,v,w,p;\nu)=uv_{x}+vv_{y}+wv_{z}+p_{y}-\nu(v_{xx}+v_{yy}+v_{ zz}),\\ & n(u,v,w,p;\nu)=uw_{x}+vw_{y}+ww_{z}+p_{z}-\nu(w_{xx}+w_{yy}+w_{ zz}).\end{split} \tag{13}\]

We now create physics-informed neural networks using backward Euler discretization for the time derivative. Other discrete schemes can be used as well, we focus on backward Euler discretization in this work without any loss of generality. For the two-dimensional case, we have

\[\begin{split} u^{pi}(t,x,y;\Delta t,\theta)=u^{pu}(t+\Delta t,x,y ;\theta)-\Delta t\,g(u^{pu}(t+\Delta t,x,y;\theta)\\ \,v^{pu}(t+\Delta t,x,y;\theta)\\ \,p^{pu}(t+\Delta t,x,y;\theta);\nu),\\ \,v^{pi}(t,x,y;\Delta t,\theta)=v^{pu}(t+\Delta t,x,y;\theta)- \Delta t\,h(u^{pu}(t+\Delta t,x,y;\theta)\\ \,v^{pu}(t+\Delta t,x,y;\theta)\\ \,p^{pu}(t+\Delta t,x,y;\theta);\nu),\end{split} \tag{14}\]

and the three-dimensional physics-informed neural networks are given by

\[\begin{split} u^{pi}(t,x,y,z;\Delta t,\theta)=u^{pu}(t+\Delta t,x,y,z;\theta)-\Delta t\,l(u^{pu}(t+\Delta t,x,y,z;\theta)\\ \,v^{pi}(t+\Delta t,x,y,z;\theta)\\ \,w^{pu}(t+\Delta t,x,y,z;\theta)\\ \,p^{pu}(t+\Delta t,x,y,z;\theta);\nu),\\ v^{pi}(t,x,y,z;\Delta t,\theta)=v^{pu}(t+\Delta t,x,y,z;\theta)- \Delta t\,m(u^{pu}(t+\Delta t,x,y,z;\theta)\\ \,v^{pu}(t+\Delta t,x,y,z;\theta)\\ \,w^{pu}(t+\Delta t,x,y,z;\theta)\\ \,p^{pu}(t+\Delta t,x,y,z;\theta);\nu),\end{split} \tag{15}\]
\[w^{p_{i}}(t,x,y,z;\Delta t,\theta)=w^{pu}(t+\Delta t,x,y,z;\theta)- \Delta t\,n(u^{pu}(t+\Delta t,x,y,z;\theta) \tag{18}\] \[v^{pu}(t+\Delta t,x,y,z;\theta)\] \[w^{pu}(t+\Delta t,x,y,z;\theta)\] \[p^{pu}(t+\Delta t,x,y,z;\theta);\nu),\]

here the superscript pi denotes a physics-informed network and pu denotes a physics-uninformed network. Since the physics-informed and uninformed networks evaluate the velocities at the same point \(t,x,y\), they need to be consistent. We enforce this using a consistency loss

\[L_{consistency}(\theta;\Delta t)= \mathbb{E}_{(t,x,y)}[\frac{|u^{pi}(t,x,y;\Delta t,\theta)-u^{pu} (t,x,y;\theta)|^{2}}{{\sigma_{u}}^{2}}]+ \tag{19}\] \[\mathbb{E}_{(t,x,y)}[\frac{|v^{pi}(t,x,y;\Delta t,\theta)-v^{pu} (t,x,y;\theta)|^{2}}{{\sigma_{v}}^{2}}],\]

in two-dimensions. The consistency loss in three-dimensions is defined as

\[L_{consistency}(\theta;\Delta t)= \mathbb{E}_{(t,x,y,z)}[\frac{|u^{pi}(t,x,y,z;\Delta t,\theta)-u ^{pu}(t,x,y,z;\theta)|^{2}}{{\sigma_{u}}^{2}}]+ \tag{20}\] \[\mathbb{E}_{(t,x,y,z)}[\frac{|v^{pi}(t,x,y,z;\Delta t,\theta)-v^{ pu}(t,x,y,z;\theta)|^{2}}{{\sigma_{v}}^{2}}]+\] \[\mathbb{E}_{(t,x,y,z)}[\frac{|w^{pi}(t,x,y,z;\Delta t,\theta)-w ^{pu}(t,x,y,z;\theta)|^{2}}{{\sigma_{w}}^{2}}].\]

The parameters \(\theta\) are then optimized to minimize the following combined loss

\[L_{MSE}(\theta)=L_{data}(\theta)+L_{consistency}(\theta). \tag{21}\]

## 3 Results

To test our method, we consider two and three-dimensional numerical datasets (section 3.1) and an experimental dataset (section 3.2). We generated the two-dimensional dataset using the open source CFD toolbox OpenFOAM [26] for the flow past a cylinder. A snapshot of the reference velocity and pressure fields of this dataset is shown in fig. 3. For the three-dimensional case, we look at the flow inside an aneurysm [27]. The three-dimensional dataset was generated using the spectral element method, and

Figure 3: A snapshot of the reference (a) x-velocity, (b) y-velocity and (c) pressure fields of the two-dimensional dataset.
the dataset is available at [https://github.com/maziarraissi/HFM](https://github.com/maziarraissi/HFM). For the experimental dataset, we calculate the velocity field for water in a channel flow using PIVLab [28] by tracking particles. A PINN solver was then used to generate the pressure field using the known viscosity of water. We then used the velocity field from PIVlab and the pressure field from the PINN solver to test the method discussed in this paper.

### Numerical datasets

For all the two-dimensional datasets in this section, we present the scalar fields \(\psi\) and pressure using an eight-layer deep, fully connected neural network with 128 neurons per hidden layer. For the three-dimensional case, we present \(\psi_{1},\psi_{2},\psi_{3}\) and pressure using a ten-layer deep neural network with 200 neurons per hidden layer. We use the swish activation function. The use of other architectures might yield better results. A cosine learning rate schedule [29] was used in all the runs reported in this work. We used a value of 2.5e-03 for \(\eta_{max}\) and 2.5e-06 for \(\eta_{min}\) to get the learning rate \(\eta\) as defined in the following equation

\[\eta=\eta_{min}+0.5(\eta_{max}-\eta_{min})\left(1+\cos\left(\frac{T_{cur}}{T_ {max}}\pi\right)\right), \tag{22}\]

where \(T_{cur}\) is the current time step and \(T_{max}\) is the total timestep. For the two-dimensional case, we choose a mini-batch size of 1024 for the spatio-temporal point cloud inside the domain. The Adam optimizer [30] was used to optimize the parameters of the neural network. We ran 100,000 iterations of the Adam optimizer for each two-dimensional case, and every ten iterations of the Adam optimizer took about 0.15 seconds. We used the same learning rate schedule and mini-batch size for the three-dimensional runs. For the three-dimensional cases, we optimized the parameters using 360,000 iterations of the Adam optimizer, where ten iterations took about 0.54 seconds.

We first tested the sensitivity of our method to the timestep size and the number of time steps. Here, the number of timesteps refers to the number of discrete time slices we randomly sample from. We do this to test the sensitivity of our method

Figure 4: Relative error for viscosity for different combinations of the number of timesteps and timestep size for the (a) two-dimensional and (b) three-dimensional numerical dataset.
to temporal resolution and the amount of data. We report the kinematic viscosity obtained for the two-dimensional dataset in table 1, where the reference value for the dimensionless kinematic viscosity was \(0.01\). For the three-dimensional dataset, the reference dimensionless kinematic viscosity was \(0.01018\), and we report the results in table 2. We show the plot for the relative errors for different combinations of timestep size and timesteps for the two-dimensional and three-dimensional cases in fig. 4. While the trend is not strictly monotonic, increasing the spatial resolution by decreasing the timestep size and increasing the amount of data improves the results. Our framework reports a low relative error for a wide range of combinations.

To test the sensitivity of our method to noise, we added Gaussian noise to the two-dimensional dataset. We report the values for viscosity with \(16\) timesteps with time step sizes \(0.01s,0.02s,0.05s,0.10s\), and \(0.20s\) at different noise levels in table 3. We plot the relative errors for different combinations of timestep sizes and Gaussian noise in fig. 5. We observed that the amount of Gaussian noise did not significantly affect the error, and our method worked well even when \(10\%\) Gaussian noise was added to the dataset. This result was in agreement with what was observed for PINNs earlier [14].

The low sensitivity to Gaussian noise might result from many spatial points in the dataset. We trained our model on fewer spatial points to test this. We randomly sampled \(60495\), \(16384\), \(4096\), \(1024\), and \(256\) spatial points at \(16\) time steps and added \(5\%\) Gaussian noise. We report the predicted viscosities for each case in table 4 and show the relative error in fig. 5. We obtained good results by randomly sampling \(4096\) points, or roughly \(1\) in \(16\) spatial points. Our method worked well for smaller time step sizes and eventually broke down when we randomly sampled only \(256\) spatial points or around \(1\) in \(256\) spatial points. Since our setup worked for sparse and noisy data, we next considered a real-world dataset obtained through experiments.

Figure 5: Relative error for viscosity for (a) different combinations of the number of timesteps and noise and (b) different combinations of the number of timesteps and number of spatial points for the two-dimensional numerical dataset. We noticed that the addition of Gaussian noise does not have a significant effect on results. Our framework eventually breaks down when only \(256\) points are randomly sampled.
### Experimental Dataset

Water seeded with 1 \(\mu\)m fluorescent polystyrene beads (Bangs Laboratories Inc., IN, USA) at 2% (w/w) concentration is used for the experimental validation. As shown in Fig. 6, a syringe pump drives the fluid flow within an oblique channel of 1 mm width and 0.4 mm height. We applied water flow at 40 \(\mu\)l/min. A 520 nm laser using an inverted microscope coupled with a confocal system (Nikon, NY, USA) for imaging and used an oil immersion 60x (0.1083 \(\mu\)m/px) lens. We collected 3000 images at 5 ms intervals (200 fps).

\begin{table}
\begin{tabular}{|c|c|c|c|c|c|} \hline
**Timesteps\(\Delta T\)** & \(0.01s\) & \(0.02s\) & \(0.05s\) & \(0.10s\) & \(0.20s\) \\ \hline
2 & 0.01043 & 0.01335 & 0.07658 & 0.1328 & 0.1795 \\ \hline
4 & 0.01001 & 0.01002 & 0.01027 & 0.01147 & 0.0139 \\ \hline
8 & 0.01 & 0.01 & 0.01011 & 0.01102 & 0.01452 \\ \hline
16 & 0.01 & 0.01 & 0.01018 & 0.01076 & 0.01345 \\ \hline
32 & 0.01022 & 0.01 & 0.01017 & 0.01069 & 0.01358 \\ \hline
64 & 0.0104 & 0.01041 & 0.01029 & 0.01093 & 0.01479 \\ \hline
128 & 0.0104 & 0.0106 & 0.01113 & 0.01222 & 0.01494 \\ \hline \end{tabular}
\end{table}
Table 1: Viscosity for 2D case

\begin{table}
\begin{tabular}{|c|c|c|c|c|c|} \hline
**Timesteps\(\Delta T\)** & \(0.01s\) & \(0.02s\) & \(0.05s\) & \(0.10s\) & \(0.20s\) \\ \hline
32 & 0.0083 & 0.0092 & 0.01005 & 0.01177 & 0.01222 \\ \hline
64 & 0.008 & 0.0092 & 0.01187 & 0.01176 & 0.01176 \\ \hline
128 & 0.0097 & 0.0094 & 0.01088 & 0.01175 & 0.01204 \\ \hline
192 & 0.0094 & 0.009746 & 0.01158 & 0.01388 & 0.01456 \\ \hline \end{tabular}
\end{table}
Table 2: Viscosity for 3D case
\begin{table}
\begin{tabular}{|c|c|c|c|c|c|} \hline
**\# points**\(\Delta T\) & \(0.01s\) & \(0.02s\) & \(0.05s\) & \(0.10s\) & \(0.20s\) \\ \hline
60945 & 0.01 & 0.01 & 0.01018 & 0.01076 & 0.01357 \\ \hline
16384 & 0.01 & 0.01 & 0.01023 & 0.01066 & 0.01156 \\ \hline
4096 & 0.0099 & 0.0097 & 0.01025 & 0.0101 & 0.01072 \\ \hline
1024 & 0.011 & 0.0157 & 0.0132 & 0.0117 & 0.01107 \\ \hline
256 & 0.05447 & 0.05492 & 0.03893 & 0.03758 & 0.04164 \\ \hline \end{tabular}
\end{table}
Table 4: Viscosity for 2D case as a function of spatial points for 16 timesteps

Figure 6: The experimental setup with the \(\upmu\)-Slide III 3in1 (ibidi Inc., WI, USA) is used for the PIV measurements. The flow inlet and outlet are labeled as A and B, respectively. The interrogation area (not to scale) is also represented using the orange square. During the experiment, the other two inlets were closed using ibidi luer locks.

\begin{table}
\begin{tabular}{|c|c|c|c|c|c|} \hline
**Noise**\(\Delta T\) & \(0.01s\) & \(0.02s\) & \(0.05s\) & \(0.10s\) & \(0.20s\) \\ \hline
0\% noise & 0.01 & 0.01 & 0.01018 & 0.01076 & 0.01173 \\ \hline
1\% noise & 0.01 & 0.01 & 0.01023 & 0.01064 & 0.01152 \\ \hline
2\% noise & 0.01 & 0.01 & 0.01023 & 0.01072 & 0.0116 \\ \hline
5\% noise & 0.01 & 0.01 & 0.01023 & 0.01066 & 0.01156 \\ \hline
10\% noise & 0.01 & 0.01 & 0.01017 & 0.01053 & 0.01151 \\ \hline \end{tabular}
\end{table}
Table 3: Viscosity for 2D case as a function of noise level for 16 timesteps with 5% noise
For post-processing PIVlab MATLAB GUI is used [28]. We imported the images in the pairwise sequencing scheme. Image pre-processing using the PIVlab interface is also applied to remove the background light intensity. The 2-D velocity field is extracted in the \(x\)-\(y\) plane using the Fast Fourier Transform (FFT) window deformation algorithm, along with three passes, i.e., 128, 64, and 32 pixel interrogation areas. Finally, the mean- \(x\) and \(y\) velocity components are calculated and exported separately.

We use the velocity field obtained from PIVLab to generate a reference pressure field. Our framework then uses the velocity and pressure fields to predict water viscosity at room temperature. We used an eight-layer deep, fully connected neural network with 128 neurons per hidden layer. We used the learning schedule described in section 3.1, and the parameters of the network were optimized using 800,000 iterations of the Adam optimizer. The reference value for the water viscosity at room temperature is 0.01 poise [31], and the value we get from our model is 0.00977 poise.

## 4 Conclusions and Future Work

It is generally challenging to assign relative weights to the loss terms while training physics-informed neural networks, especially with multiscale data. We propose a novel solution for this challenge. By using backward Euler discretization for temporal derivatives instead of automatic differentiation, we can use the data's statistical properties to get the loss terms' relative weights. In this work, we consider the two and three-dimensional Navier-Stokes equations and determine the kinematic viscosity using spatio-temporal data on the velocity and pressure fields.

For the two-dimensional case, we look at the flow past a cylinder and flow in an aneurysm for the three-dimensional case. We test the sensitivity and robustness of our method against the timestep size, the number of timesteps, noise in the data, and the spatial data resolution. Since our method worked well for a wide range of numerical data, we tested our method using experimental data. We used the velocity field from experimental PIV measurements of a channel flow to generate a reference pressure field. We tested our framework using this velocity and reference pressure fields to get water viscosity at room temperature. We demonstrated that our framework worked well with an experimental dataset. This work uses spatio-temporal data on the pressure and velocity fields as input. For future work, using just the velocity field as an input and solving for the pressure field can be explored. Then the velocity field from PIV measurements can be used directly to learn the viscosity and the pressure field for both two and three-dimensional flows.

## 5 Acknowledgements

A.M.A. acknowledges financial support from the National Science Foundation (NSF) through Grant No. CBET-2141404.
