### Abstract

Most biological fluids are viscoelastic, meaning that they have elastic properties in addition to the dissipative properties found in Newtonian fluids. Computational models can help us understand viscoelastic flow, but are often limited in how they deal with complex flow geometries and suspended particles. Here, we present a lattice Boltzmann solver for Oldroyd-B fluids that can handle arbitrarily shaped fixed and moving boundary conditions, which makes it ideally suited for the simulation of confined colloidal suspensions. We validate our method using several standard rheological setups and additionally study a single sedimenting colloid, also finding good agreement with the literature. Our approach can readily be extended to constitutive equations other than Oldroyd-B. This flexibility and the handling of complex boundaries hold promise for the study of microswimmers in viscoelastic fluids.

### Graphic abstract

### Similar content being viewed by others

## 1 Introduction

Recent years have seen a surge of interest in the study of viscoelastic fluids, due to increased experimental understanding and several intriguing results that were obtained in these media. In particular, microswimmers in viscoelastic fluids show a richer set of behaviors than possible in simple (Newtonian) fluids, which include the self-propulsion of a microswimmer with a single hinge [1, 2], which is forbidden in a Newtonian fluid at low Reynolds number by Purcell’s scallop theorem [3]; enhanced rotational diffusion of thermophoretic Janus swimmers, due to time-delayed translation–rotation coupling in polymer suspensions [4]; a peak in the motility of *Escheria coli* bacteria as a function of the polymer concentration and thus complexity of the fluid [5]; and a fundamental change in the way a microorganism propels in response to the rheology of the medium [6]. With the majority of industrially and biologically relevant fluids being viscoelastic [7, 8], many more such surprises lie ahead of us.

This has motivated the development of a wide range of theoretical and numerical methods. However, solving the associated hydrodynamic problem remains an open challenge, both in terms of efficiency and in defining the relevant constitutive equations. Much of the numerical work has focused on well-established, albeit basic, models of complex media, such as polymeric fluids described by Oldroyd-B [9] and FENE-P [10, 11]. Examples of such solvers applied to microfluidic problems include the finite volume method [12, 13], the finite element method [14, 15], multi-particle collision dynamics (MPCD) [16, 17], dissipative particle dynamics [18], the immersed boundary method [6], smoothed-particle hydrodynamics [19, 20], as well as explicit-polymer models based on Stokesian dynamics [21] and MPCD [22]. The open problem is how to simulate a fluid with a well-defined rheological response, while also allowing for the incorporation of colloidal particles. Lattice Boltzmann [23,24,25] (LB) methods hold particular promise to achieve this goal due to their computational efficiency [26] and facile boundary [27] and particle coupling [28,29,30,31], as has been demonstrated in Newtonian media. A wide variety of viscoelastic LB schemes have been conceived over the years [32,33,34,35,36,37,38,39,40,41,42,43,44,45]. However, despite this long history, which we will summarize in Sect. 3.2, there remain multiple unresolved issues, especially with regard to boundary conditions.

In this paper, we address the issues of simulation of a viscoelastic fluid using LB with arbitrarily shaped, moving boundaries. Our method is inspired by the Su et al. [43] algorithm for an Oldroyd-B fluid, which we re-derive as a finite volume scheme similar to that of Oliveira et al. [46]. This ensures momentum conservation and allows us to introduce a boundary coupling that makes no assumptions on the stress at the boundary. Compared to the LB schemes described in the literature, further advantages include low memory usage and the absence of unphysical diffusion terms. After summarizing the relevant theory in Sect. 2 and laying out our numerical method in Sect. 3, we benchmark our algorithm using several standard rheological tests: time dependence of the planar Poiseuille flow in Sect. 4.1, steady shear flow in Sect. 4.2, the instabilities in lid-driven-cavity flow in Sect. 4.3, and extensional flow in the four-roll mill in Sect. 4.4. Next, we examine the effect of the coupling of translation and rotation on the sedimentation of a sphere in Sect. 4.5, showing that we reproduce the shear-induced speed-up. We discuss our findings and conclude with an outlook on future applications in Sect. 5.

## 2 Theory

In this section, we summarize the equations underlying viscoelastic flow problems. They are commonly split into a Newtonian part and an additional constitutive equation, which describes the stress evolution. In terms of notation, bold symbols denote vectors \((\varvec{Z})_i=Z_i\) and bold sans-serif symbols denote tensors .

### 2.1 Generalized Stokes equation

The micro-scale flows under consideration take place at low Reynolds numbers, so the hydrodynamics are governed by the time-independent Stokes equations,

The first equation corresponds to momentum conservation, and the second equation is the incompressibility condition. *d* is the number of spatial dimensions, and \(\varvec{u}\) and are the fluid’s flow velocity and stress at position \(\varvec{r}\) and time *t*. \(\varvec{F}^\text {ext}\) is a force applied to the fluid.

A Newtonian fluid’s stress consists of a viscous stress and a pressure *p*:

which simplifies Eq. (1) to

\(\eta _\text {n}\) is the viscosity of the Newtonian fluid.

The more general case of non-Newtonian fluids adds an extra stress to Eq. (3). evolves according to a constitutive equation. Its effect on the flow may be absorbed into Eq. (5)’s force via

where \(\hat{\varvec{e}}_i\) is the *i*-th unit vector. The total force \(\varvec{F}^\text {ext}=\varvec{F}+\varvec{F}^\text {p}\) is a sum of an applied force and the force resulting from viscoelastic stress.

### 2.2 Oldroyd-B fluids

There are many different constitutive equations that describe the wide range of complex fluids encountered in applications. These include Oldroyd-B [9], Jeffreys [47, 48], Giesekus [49], FENE-P [10], FENE-CR [50], or Phan-Thien-Tanner [51]. For simplicity’s sake and because it is widely studied, we will focus on Oldroyd-B. We will later indicate how our method can be extended to some of the above more realistic models. Oldroyd-B’s corresponds to the conformation tensor of the constituent polymers, averaged over a small control volume [52]. It makes several simplifying assumptions about the fluid, including that it is made up of dumbbell polymers with zero equilibrium length and that these are very dilute [53], to arrive at the following constitutive equation:

Here, the first term corresponds to advection, the next two terms are due to the polymers being stretched by the velocity gradient, and the final two terms represent the polymer relaxation. \(\lambda _\text {p}\) is the relaxation time of the polymers, while \(\eta _\text {p}\) refers to the viscosity added to the fluid by their presence. For use with the finite volume scheme in Sect. 3.3, flux and source terms are identified in order to recast the equation as a conservation law:

### 2.3 Dimensionless numbers

It is common practice in fluid mechanics to introduce certain dimensionless numbers. Many phenomena do not depend on precise parameter values, but rather on the relative significance of individual physical effects. The Reynolds number gives the ratio of inertial forces to viscous forces:

where *L* is a characteristic length scale of the flow and *U* a characteristic velocity. \(\mathrm {Re}\) represents the relative importance of inertia. The Stokes Eq. (1) is only valid in the limit of \(\mathrm {Re} \ll 1\). The Deborah number is determined by the ratio of the elastic relaxation time to the characteristic time scale of the flow [54]:

thus representing the degree of elasticity in response to a deformation. The Weissenberg number relates the elastic relaxation time to the characteristic rate at which the deformation is driven [54]:

Finally, it is convenient to introduce the polymer viscosity fraction

which can easily be varied while keeping the total viscosity

constant.

## 3 Numerical methods

Just as the equations in Sect. 2 are split into a Newtonian part and a viscoelastic constitutive equation, we employ two separate numerical methods. The former is solved via lattice Boltzmann (LB), while the latter uses the finite volume (FV) method.

### 3.1 Lattice Boltzmann

LB [23, 25] constructs solutions to Eq. (5) from the Boltzmann transport equation (BTE), which derives from the same conservation laws. The BTE describes the time evolution of \(f(\varvec{r}, \varvec{v}, t)\), which is the probability distribution function of finding a single fluid molecule with velocity \(\varvec{v}\) at position \(\varvec{r}\) and time *t*. LB discretizes the BTE on a lattice, typically a square/cubic lattice in two/three dimensions, with grid spacing \(\Delta x\) and discrete time steps \(\Delta t\). Relaxation of *f* toward its Maxwellian equilibrium is linearized, and only a finite set of velocities \(\varvec{c}_i\) is permitted to allow probability to be exchanged solely between neighboring cells. The probability distribution is thus replaced by the populations \(f_i(\varvec{r},t)=f(\varvec{r}, \varvec{c}_i, t)\), with their equilibrium values \(f_i^{\text {eq}}(\varvec{r},t)\). We use the D3Q19 velocity set in three dimensions and D2Q9 for two-dimensional systems. In the general D*d*Q*q* notation, *d* refers to the dimensionality and *q* to the number of velocity vectors pointing to neighbor cells—here these are the six face and twelve edge neighbors (or four edge and four corner neighbors in two dimensions). The employed two relaxation time (TRT) collision operator relaxes symmetric (\(+\)) and antisymmetric (−) linear combinations of \(f_i\) separately, and only the symmetric relaxation time \(\lambda _+\) affects the viscosity of the fluid. \(\lambda _-\) can be tuned to improve the accuracy of boundary conditions [55].

The full LB method is given by

with

and \(-i\) defined via \(\varvec{c}_{-i}=-\varvec{c}_i\). The local fluid density \(\rho (\varvec{r},t)\) appears explicitly because LB does not simulate a perfectly incompressible fluid. For consistency, we did verify in our simulations that the fluid does not compress appreciably. The populations \(f_i\) and the macroscopic flow fields are connected via

\(\Delta _i(\varvec{r},t)\) in Eq. (16) represents the force \(\varvec{F}^\text {ext}\) applied to the fluid. One possible expression for it is given by Guo et al. [56,57,58]:

with

where \(w_i\) is the lattice weight factor for \(\varvec{c}_i\), \(\cdot \) is the scalar/dot product, \(\otimes \) is the tensor/dyadic product, and \(\mathrm {Tr}\) is the trace of a tensor.

Velocity boundary conditions can be imposed on the fluid by using

where \(\varvec{r}_\text {b}\) is a boundary node with velocity \(\varvec{u}_\text {b}\) and \(\varvec{r}_\text {b}+\varvec{c}_i\Delta t\) is a fluid node. For no-slip conditions \(\varvec{u}_\text {b}=0\), this scheme corresponds to a bounce-back of the population.

### 3.2 Background on viscoelastic LB

As early as 1997, Giraud et al. [32, 33] used LB to compute the response of the Jeffreys fluid. This was followed up by Ispolatov and Grant [34], who employed LB to solve a linear Maxwell model, by implementing the elastic stress contribution as a body force onto their fluid. Similar approaches were followed by Li and Fang [35] and Frantziskonis [36]. Later, Frank and Li [37, 38] went beyond the body-force coupling and introduced the effect of elastic stress directly into the second moment of the equilibrium distribution, which has recently been revisited by Dellar [39]. Other coupling forms were considered by Onishi et al. [40] and Osmanlic and Körner [41], who employ a Fokker–Planck-like evolution of microscopic dumbbells in a viscous fluid. This type of system is theoretically known to result in a viscoelastic response that resembles Oldroyd-B [59]. More direct approaches to reproducing Oldroyd-B were followed by Karra [42] and Su et al. [43], who solved the stress evolution equation for the corresponding constitutive relation directly using the LB fluid velocity as input to a finite difference scheme. Malaspinas et al. [44] and Su et al. [45] similarly used an LB scheme as a generic differential equation solver and treated the viscoelastic stress tensor component-wise, for both the Oldroyd-B and FENE-P constitutive relations. Phillips and Roberts [60] provide a more in-depth review of the cited methods for viscoelastic fluids, as well as methods for generalized Newtonian fluids; for a discussion of LB methods that deal with viscoelastic behavior of active fluids, see the review by Carenza et al. [61].

The LB schemes listed above are not applied to problems with boundaries [32, 37], do not require explicit treatment of the stress [34,35,36, 38], or use bounce-back rules to impose specific boundary conditions on the stress [33, 39]. Some extrapolate stress onto boundaries to allow for cases where no analytic expression exists [44, 45], while others can only be applied to systems for which the stress at the boundary is known beforehand [43]. In the following, we build upon this body of knowledge and introduce a general method capable of handling complex and moving boundaries. By doing so, we overcome the limitations of previous viscoelastic LB algorithms.

### 3.3 Finite volume method

Our method is inspired by an LB-coupled finite volume (FV) solver for the electrokinetic equations [62] and has similarities to other FV Oldroyd-B solvers [46]. FV methods [63] are well suited for solving problems governed by conservation laws such as Eq. (8) since they guarantee the conservation of, e.g., momentum and energy to machine precision. We found that the hybrid scheme of finite differences (FD) and LB originally suggested by Su et al. [43] led to violation of energy conservation in the constitutive equation in the presence of boundaries, which translated into a violation of the conservation of momentum. Moving boundary simulations as presented in Sect. 4.5 were therefore impossible.

#### 3.3.1 Discretization

Equation 8 is averaged over one cell’s volume \(V=\Delta x^d\) with surface unit normal \(\hat{\varvec{n}}\) to become

where Gauß’s divergence theorem has been applied and the overbar indicates the volume average. By locating and at the cell center and between two cells, the discrete form of this equation is obtained as

where we have used the same grid spacing and time step as in Sect. 3.1. The neighbor set \(\{\varvec{c}_i\}\) does not necessarily need to match the one used in Sect. 3.1: we have found D3Q27/D2Q9 to deliver no appreciable advantage over D3Q7/D2Q5 [64] and have thus selected the latter for its lower computational cost.

We numerically interpolate as

and insert these expressions into Eq. (9) to obtain

where the projection onto \(\varvec{c}_i\) and the prefactor

account for the case of \(q>2d+1\) [62]. We will replace Eq. (30) in Sect. 3.3.2 with a different expression to improve numerical stability.

We need to numerically differentiate \(\varvec{u}\) and average over the volume of one cell:

Making the central-point approximation

and inserting Eq. (29) yields the first-order FV discretization

which is identical to the corresponding FD scheme. Inserting it into Eq. (10) then yields .

The force Eq. (6) is similarly discretized by averaging over the volume of a cell:

where \(\tau _{ij}(\varvec{r}+\frac{1}{2}\varvec{c}_i\Delta t)\) can be obtained via Eq. (29).

Boundaries across which no stress is transported can be imposed on the FV scheme by using

where \(\varvec{r}_\text {b}\) is a boundary node and \(\varvec{r}_\text {b}+\varvec{c}_i\Delta t\) is a fluid node. needs to be extrapolated so that the force can continue to be obtained via Eq. (36). We found constant extrapolation

to be sufficient, but linear or quadratic extrapolation could be employed as needed.

#### 3.3.2 Stability improvements

FV and FD schemes are known to exhibit numerical instabilities in certain situations, which result in spatial oscillations or “wiggles” [64]. This is a particularly prominent problem in the context of Oldroyd-B as the model’s Péclet number [63], which relates advective transport to diffusive transport, is infinite due to the absence of a diffusive term in Eq. (7). We observed stress wiggles when performing the simulations of Sects. 4.5 and 4.4 as described in Sect. 3.3.1. Solutions proposed for Oldroyd-B include: using higher-order differentiation schemes [43], inserting an artificial diffusion term [44], or storing \(\varvec{u}\) and on two separate grids shifted relative to each other by half a cell [46, 65]. These methods increase computational cost, modify the physics of the system, and make the implementation cumbersome, respectively, so we consider alternative techniques suggested in general FV literature. These include higher-order interpolation [63, 66] and differentiation [67] schemes, as well as upwind schemes [62, 63].

We resorted to the latter and chose an upwind variant called *corner-transport upwind scheme* suggested by Refs. [62, 68] and employed in our previous work [69, 70]. Upwind schemes calculate advective fluxes like Eq. (30) not by interpolating quantities to the midpoint between two cells, but by using the quantity from either cell, depending on which way the flow points [63]. Reference [62]’s method is geometrically motivated by virtually displacing a cell at \(\varvec{r}\) by its velocity \(\varvec{u}(\varvec{r},t)\Delta t\) and calculating the virtual cell’s overlap volume with all neighboring cells. This overlap corresponds to the fraction of to be transferred to the respective neighboring cell. While this in principle results in fluxes in all D3Q27/D2Q9 directions, fluxes beyond the D3Q7/D2Q5 neighbor set are \({\mathcal {O}}(u^2)\), making them negligible here.

### 3.4 Moving boundaries

One way of coupling particles to an LB fluid is by the moving boundary method. It was introduced by Ladd [30] and later enhanced by Aidun et al. [31]. This method is applicable for particles much larger than the size of a grid cell and considers the cells inside the particle as no-slip conditions in the particle-co-moving frame. This corresponds to a velocity boundary condition of

which can be applied via Eq. (26). \(\varvec{r}\), \(\varvec{v}\), and \(\varvec{\omega }\) are the position, linear, and angular velocity of the particle. Applying the boundary condition to the fluid transfers linear and angular momentum to the particle, corresponding to a force and torque

The particle trajectory is obtained by summing these forces and torques, along with any externally applied ones, and integrating numerically with a symplectic Euler integrator.

As a particle moves across the lattice, the set of cells it overlaps changes. When a cell at \(\varvec{r}_\text {f}\) is converted from fluid to solid, its fluid populations are deleted. In the reverse case, new fluid populations are created at their equilibrium value, \(f_i(\varvec{r}_\text {f},t)=f_i^\text {eq}(\varvec{r}_\text {f},t)\) from Eq. (19), whose velocity \(\varvec{u}_\text {b}(\varvec{r}_\text {f},t)\) is given by Eq. (39). Momentum conservation during creation and destruction of populations is ensured by applying a force to the particle that balances any momentum destroyed or created:

The moving boundary method has previously been extended to FV schemes [70, 71], but only in the context of ion concentrations propagating according to the electrokinetic equations. In this paper, we take a similar path to apply it to the of a viscoelastic medium. Refs. [70, 71] take precautions to ensure that charge is conserved. We do the same here to ensure that stress—whose diagonal elements correspond to stored energy—is not created or destroyed while cells are converted between fluid and solid. Refs. [70, 71] further calculate the fraction of a cell that is overlapped by the particle and use that information to smooth out the conversion process, which they reported to significantly decrease oscillations in the particle’s speed. For the simulations in Sect. 4.5, we found such smoothing to be unnecessary.

A fluid cell at \(\varvec{r}_\text {f}\) that is destroyed in front of the particle has its stress distributed among the surrounding \(N_\text {f}\) fluid cells as

A cell behind the particle that is created with new fluid receives

and the corresponding amount is removed from the neighboring cells:

### 3.5 Implementation and extensibility

The methods described above are implemented using the waLBerla C++ framework [26, 72]. It allows for efficient and highly parallelized implementation of local algorithms on regular grids and provides several LB implementations and a rigid-body dynamics module. The Python module pystencils [73] can be used to automatically generate code for grid-based algorithms, either for use in Python or for waLBerla. We have extended it with a generator for finite volume discretizations that automatically derives the expressions in Sect. 3.3 when provided with the Oldroyd-B Eqs. (8) and (10). By instead supplying, for example, the FENE-P constitutive equation [10], we could simulate that model without writing any additional code.

There are several other fluid dynamics software packages that allow the user to provide such equations and automatically derive discretizations for them, e.g., Dedalus [74] or OpenFOAM [75]. The combination of pystencils and waLBerla, however, is unique in that it allows for arbitrarily shaped boundary conditions that change over time, which can be put to use for the moving boundaries of Sect. 3.4. We forgo waLBerla for the two-dimensional simulations, since they do not require rigid-body dynamics or parallelization, and run these simulations completely from Python. In this case, LB is provided by the lbmpy module [76].

## 4 Validation and results

In this section, we solve multiple rheological benchmark systems to verify the correctness of our algorithm and implementation by comparing against results from literature. We then simulate a system involving moving boundary conditions and translation–rotation coupling in order to demonstrate the strength of the method.

### 4.1 Time-dependent Poiseuille flow

The planar Poiseuille geometry consists of an infinitely long channel of width *L*, through which flow is driven by a homogeneous force along the channel, \(\varvec{F}=F_x\hat{\varvec{e}}_x\). The channel walls impose a no-slip condition \(\varvec{u}((x,0)^\intercal ,t)=\varvec{u}((x,L)^\intercal ,t)=0\), while the infinite length can be achieved via periodic boundary conditions in *y*-direction. This setup is illustrated in Fig. 1 and results in a parabolic steady-state flow profile. Starting this flow in a resting Newtonian fluid causes the steady-state flow to be approached in a monotonous fashion. In a viscoelastic medium, however, the flow velocity can overshoot its steady-state value and then decay to it on a time scale of \(\lambda _\text {p}\). This is due to the storage of energy in the elastic medium, which is released back into the fluid on the time scale \(\lambda _\text {p}\). Reference [77] provides an analytical expression for the time-dependent velocity at the center of the channel, \(\varvec{u}((x,L/2)^\intercal ,t)\), in a *liquid B’* model. This model has been shown to be equivalent to Oldroyd-B [78, 79].

We choose the channel width \(L=28\Delta x\), the applied force \(F_x=10^{-5}\rho \Delta x^4/\Delta t^2\), Newtonian viscosity \(\eta _\text {n}=\rho \Delta x^2/\Delta t-\eta _\text {p}\), polymer viscosity ratios \(\beta \in \{0.1,0.3,0.5,0.7,0.9\}\), and polymer relaxation times \(\lambda _\text {p}/\Delta t\in \{1000,3000,5000,7000,9000\}\) for our test simulations. This corresponds to a Reynolds number of

which is well within the low-Reynolds regime we are interested in.

Figure 2 shows the flow velocity \(u_x((x,L/2)^\intercal ,t)\) over time for various polymer viscosity ratios \(\beta \) at constant polymer relaxation time \(\lambda _\text {p}=3000\Delta t\). One can see that the magnitude of the overshoot increases with \(\beta \). For the largest values of \(\beta \), the flow can even decay to its final speed in an oscillatory fashion. Figure 3 keeps \(\beta =0.3\) constant and varies \(\lambda _\text {p}\). Here it is clear that the magnitude of the overshoot increases with \(\lambda _\text {p}\), which is also the characteristic decay time of the overshoot.

Figures 2 and 3 additionally show the analytical result from Ref. [77] for comparison. The agreement with the analytics can be improved to around \(1\%\) in all cases if *L* is used as a fit parameter. This is justified by the fact that the boundary position in LB is not guaranteed to be exactly at the edge of the cell [80] and that the extrapolation of Eq. (38) introduces an error for the FV method. The resulting *L* differs from the input parameter by \(\pm 0.6\) cells, or \(\pm 0.3\) per boundary, well within the range expected for regular LB.

### 4.2 Steady shear flow

The planar Couette geometry is similar to that of Sect. 4.1, but replaces the applied force with a velocity boundary condition of \(\varvec{u}((x,L)^\intercal ,t)=u_0\hat{\varvec{e}}_x\) on one of the planes, as illustrated in Fig. 4. This relative motion leads to a linear steady-state velocity profile across the channel. The first normal stress difference,

is expected to be constant over the entire channel, as obtained by solving Eq. (7) with the given velocity profile. We choose the channel width \(L=28\Delta x\), the applied velocity \(u_0=10^{-3}\Delta x/\Delta t\), Newtonian viscosity \(\eta _\text {n}=\rho \Delta x^2/\Delta t-\eta _\text {p}\), polymer viscosity ratios \(\beta \in \{0.2,0.4,0.6,0.8\}\), and polymer relaxation times \(\lambda _\text {p}/\Delta t\in [1000,20000]\) for our test simulations. They are run until sufficiently converged, which we find to be the case at \(t=10\lambda _\text {p}\). We find that \(N_1\) agrees with the prediction to within \(0.2\%\) across all parameters. Appreciable deviations (\(\sim 5\%\)) are only seen in the cells directly at the boundaries, where this is expected due to the stress extrapolation of Eq. (38).

### 4.3 Lid-driven cavity

The lid-driven cavity consists of a square flow cell of edge length *L*, with no-slip boundaries on three sides and a constant velocity boundary \(\varvec{u}((x,L)^\intercal ,t)=u_0\hat{\varvec{e}}_x\) on the top side. This is depicted in Fig. 5, which also illustrates the shape of the resulting flow: a primary vortex develops near the top center of the flow cell and secondary vortices arise in the lower corners. The exact position of the center of the primary vortex, as well as the position *y* of the minimum of \(u_x((L/2,y)^\intercal ,\infty )\) and the positions *x* of the minimum and maximum of \(u_y((x,L/2)^\intercal ,\infty )\), varies with the flow parameters and has been extensively studied in literature [81,82,83,84,85], making them well-suited for comparison in the following.

We choose width and height \(L=194\) for the flow cell, Newtonian viscosity \(\eta _\text {n}=\rho \Delta x^2/\Delta t-\eta _\text {p}\), applied velocity \(u_0=10^{-4}\Delta x/\Delta t\), polymer viscosity ratio \(\beta =0.5\), and polymer relaxation times \(\lambda _\text {p}\) such that Weissenberg numbers \(\mathrm {Wi}\in [0,1]\) are obtained. For \(\mathrm {Wi}=0\), \(\beta \rightarrow 0\) is also used. The Weissenberg and Deborah numbers coincide as [82]

for the system under consideration. The Reynolds number is given by

again placing us in the low-Reynolds regime.

For numerical reasons, the velocity boundary condition is not applied as given above. Instead, a regularization is used to remove the infinite flow divergence in the top corners. A common choice is

This regularization leaves the qualitative flow features untouched, but thwarts quantitative comparison with the unregularized simulations of Ref. [81]. The same regularization is employed by Refs. [82,83,84,85] and shall be used in the comparison below.

Figure 6 shows the positions of the primary vortex and the flow velocity extrema in our simulations. Error bars correspond to the size of a cell plus the potential deviation of the true boundary position from the prescribed boundary position. One can see that the general trend from Refs. [82,83,84,85] is recovered semi-quantitatively, with the exception of the nonlinear deviation of the *x*-component of the vortex center. Results vary significantly between these references, so that a quantitative comparison is not drawn. However, in view of this, the result in Fig. 6 gives confidence in our method’s accuracy. The speed with which our results were obtained, as well as the ability to refine these significantly, provides opportunities for future benchmarking.

The flow velocity at the points of interest is shown in Fig. 7. Values differ between Refs. [82,83,84,85] by factors of up to 2, so we only plot the comparison to Ref. [85]. This reference has matching flow velocities at \(\mathrm {Wi}\rightarrow 0\) and exhibits the same trend of decreasing velocity magnitudes as our results. The vortex is observed to move toward the top left as \(\mathrm {Wi}\) is increased. The minimum of \(u_x\) moves down slightly, while both the minimum and the maximum of \(u_y\) move toward the left. The deviations from the results in literature are expected as the system is very sensitive to resolution, especially at larger \(\mathrm {Wi}\). Our resolution was chosen such that the results had sufficiently converged.

We also performed one simulation at \(\beta \rightarrow 0\), the Newtonian case, and observe that this yields a different velocity than \(\mathrm {Wi}\rightarrow 0\) at constant \(\beta =0.5\). The velocity obtained in the former way agrees with that reported by Ref. [82] to within \(1\%\). The latter way corresponds to the case of instantaneous polymer relaxation, but not vanishing viscoelasticity.

### 4.4 Four-roll mill

The four-roll mill consists of a square cell with length *L* and periodic boundary conditions. A force field of

is applied to it, resulting in four counter-rotating rolls as illustrated in Fig. 8. Reference [86] provides an analytical prediction for the steady-state stress in the vicinity of the central point, where the flow is purely extensional, i.e., \(\varvec{u}((L/2,L/2)^\intercal ,t)=\alpha (\hat{\varvec{e}}_x-\hat{\varvec{e}}_y)\).

We choose cell size \(L=214\sqrt{2}\Delta x\), Newtonian viscosity \(\eta _\text {n}=1.5\rho \Delta x^2/\Delta t\), polymer viscosity ratio \(\beta =\frac{1}{3}\), maximum velocity \(u_0=10^{-3}\Delta x/\Delta t\), and polymer relaxation times \(\lambda _\text {p}/\Delta t\in \left[ 1000,24000\right] \). The simulation is run until sufficiently converged, which we find to be the case at \(t=20\lambda _\text {p}\). The Weissenberg number is given by [86, 87]

and the Reynolds number is low at

We found that our simulations lead to a decoupling of the stress at the center point from the rest of the domain due to the upwind scheme from Sect. 3.3.2. To avoid this, we rotated the lattice by \(45^\circ \) relative to the system as indicated in Fig. 8, while ensuring that the periodic continuation of the system remains intact. We would like to stress that this is a rather unusual situation, which only appears here due to the high level of symmetry and the divergence at the central point. Such behavior will not commonly appear in soft matter systems, but when it does, it is easily identified in the stress profiles. This gives users a means to eliminate potentially problematic simulation runs.

Figure 9a–d shows the stress component \(\tau _{xx}\) along a vertical line through the center of the cell, which is marked with a red cross in Fig. 8. A comparison with Ref. [86] is drawn by fitting with its local solution,

We fit via *C* while keeping \(\mathrm {Wi}_\text {eff}=\lambda _\text {p}\alpha \) constant, as well as via both *C* and \(\mathrm {Wi}_\text {eff}\). We find that \(\mathrm {Wi}_\text {eff}\) only differs by less than \(1\%\) between the two fits, yet the latter fit is significantly better. This is because fitting an exponent is very sensitive to small deviations. For \(\mathrm {Wi}_\text {eff}<1/4\), the structure of the stress profile is not captured well by the fit. This is due to the lack of a singularity, as Eq. (54) was constructed with a singularity in mind [86]. Beyond this value, three regimes of solutions are recovered: continuous and differentiable at the center (\(\mathrm {Wi}_\text {eff}< 1/3\)), continuous but not differentiable at the center (\(1/3\le \mathrm {Wi}_\text {eff}< 1/2\)), and diverging at the center (\(\mathrm {Wi}_\text {eff}> 1/2\)). We reproduce the expected regimes, albeit with the caveat that divergences in our scheme are not present, due to the smoothing of solutions that its discretization imposes. Figure 9e plots \(\mathrm {Wi}_\text {eff}\) that we obtained from the fits via \(\mathrm {Wi}\). Comparison with the corresponding plot from Ref. [86] is excellent up to \(\mathrm {Wi}_\text {eff}\approx 0.4\) (\(\mathrm {Wi}\approx 0.75\)), as expected due to implicit smoothing of the divergences.

### 4.5 Settling sphere

So far, all systems investigated were two-dimensional and had constant boundary conditions. To demonstrate our algorithm’s capabilities beyond this, we simulate the sedimentation of a rotating sphere. A sphere of radius *R* is placed in a cubic box of size \(L^3\) with periodic boundary conditions. A constant force \(\varvec{F}=F_z\hat{\varvec{e}}_z\) is applied to the sphere and the counterforce \(-\varvec{F}\) is distributed evenly among all fluid cells so that the net momentum of the system remains zero. Furthermore, a constant torque \(\varvec{M}=M_z\hat{\varvec{e}}_z\) is applied to the sphere to rotate it around the *z*-axis; a counter-torque on the fluid is not needed [88]. The geometry is illustrated in Fig. 10.

We choose our parameters as \(R=8\Delta x\), \(L/R\in [7.5,30]\), \(F_z=0.008\rho \Delta x^4/\Delta t^2\), \(\eta _\text {n}=\frac{1}{6}\rho \Delta x^2/\Delta t\), \(\eta _\text {p}/\eta _\text {n}\in \{0,\frac{1}{2},1,2\}\) and \(\lambda _\text {p}=6000\Delta t\). The simulation is run until the velocity \(\varvec{v}\) of the sphere has converged, for which \(t=10\lambda _\text {p}\) tends to suffice. We can assume \(M_z=0\) since it does not change the order of magnitude of the sedimentation velocity \(\varvec{v}\) [89] and employ Stokes’ law,

in order to estimate the Reynolds number for our parameter range as

which lies well in the low-Reynolds regime. The Weissenberg and Deborah numbers of the system are given by [89]

where \(\varvec{\omega }=\omega _z\hat{\varvec{e}}_z\) is the measured angular velocity of the sphere. \(v_0\) is the sedimentation velocity measured for \(\omega _z=0\), with all other parameters kept equal. \(\omega _z\) can be varied by changing the applied torque \(M_z\). \(M_z\) is chosen such that we cover a range of Weissenberg numbers while staying below a certain value of the tangential velocity \(v_\text {t}=\omega _zR\) in order to not jeopardize the LB’s stability. To achieve this, we define a maximum surface Reynolds number

which can be used to obtain a maximum allowed Weissenberg number as

The parameters provided above correspond to four sets of simulations with different polymer viscosity fractions \(\beta \). Within each set, the variation of \(\omega _z\) or \(M_z\) corresponds to a change in \(\mathrm {Wi}\), which makes the horizontal axis of Fig. 11. To obtain the value on the vertical axis, first an exponential decay is fitted to \(\varvec{v}(t)\) to extrapolate to \(t\rightarrow \infty \), and then simulations at different *L* are used to extrapolate it to \(L\rightarrow \infty \). The fit error of these two processes is used to obtain the plot error bars. In Fig. 11, we also compare to an analytical solution by Housiadas [89], who expanded \(v/v_{\text {Stokes}}\) in terms of \(\mathrm {De}\) for arbitrary \(\beta \) and \(\chi =\mathrm {Wi}/\mathrm {De}\). Agreement is mostly within error bars up to \(\mathrm {Wi}\approx 1\). Deviations beyond that are comparable to those found by Ref. [89]’s own comparison to numerical results from Ref. [90] for similar parameters. This shows that our method reproduces the analytical solution in its range of validity, while behaving similar to other methods beyond that realm.

## 5 Summary and outlook

We have introduced a method to simulate Oldroyd-B fluids with lattice Boltzmann. It uses moving boundaries to allow for the simulation of suspended colloids. We validated our method against several rheological benchmark problems and determined it to correspond well with literature for Weissenberg and Deborah numbers and viscosity fractions between zero and one, a regime relevant for many colloidal systems. We also validated our method for a specific colloidal problem, a sphere sedimenting under an applied torque, where analytical predictions are recovered in their regime of validity. Computational effort scales linearly with the number of fluid cells, while the computational cost of adding particles is negligible compared to that of simulating the fluid. Published data on the benchmarks we considered for this work covered only a small parameter space, i.e., the few most relevant points, therefore we will make our full data set available to serve as a reliable reference for future investigations. The simulation code will also be provided to enable others to study similar systems at parameters and resolutions of their choosing. Finally, thanks to the use of automatic code generation, our model and implementation are easily extensible to other viscoelastic models. Incorporating thermal fluctuations [91] is also conceivable.

Our viscoelastic, moving-boundary LB facilitates future study of dense colloidal suspensions in viscoelastic fluids. This might include the collective sedimentation of colloids [92], which goes beyond the single-body effects discussed in Sect. 4.5. The field of self-propelled colloids is of particular interest to us. Previous reports of viscoelastic enhancement of rotational diffusivity [4], for example, have spurred interest in the community. Simulation studies [22], however, could not discern whether this was an effect of viscoelasticity or merely of an inhomogeneous polymer concentration. Our method does away with the explicit consideration of polymers and might settle such questions. Besides effective propulsion models [22, 93], fully resolved propulsion models [70] might also be used, which would permit investigating complex phenomena arising from the interplay of hydrodynamics, viscoelasticity, electrostatics and phoretic interactions, such as those experimentally studied in Ref. [94]. Our new and extensively validated method provides a first stepping stone toward such future physical modeling.

## Data Availability Statement

This manuscript has associated data in a data repository. [Authors’ comment: The data presented in this publication is available at https://doi.org/10.24416/UU01-2AFZSW, along with the numerical code and analysis scripts used to obtain this data.]

## References

T. Qiu, T.C. Lee, A.G. Mark, K.I. Morozov, R. Münster, O. Mierka, S. Turek, A.M. Leshansky, P. Fischer, Nat. Commun.

**5**, 5119 (2014)T. Normand, E. Lauga, Phys. Rev. E

**78**, 061907 (2008)E. Purcell, Am. J. Phys.

**45**, 3 (1977)J.R. Gomez-Solano, A. Blokhuis, C. Bechinger, Phys. Rev. Lett.

**116**, 138301 (2016)V.A. Martinez, J. Schwarz-Linek, M. Reufer, L.G. Wilson, A.N. Morozov, W.C. Poon, Proc. Natl. Acad. Sci.

**111**, 17771 (2014)C. Li, B. Qin, A. Gopinath, P.E. Arratia, B. Thomases, R.D. Guy, J. R. Soc. Interface

**14**, 20170289 (2017)R.G. Larson,

*The Structure and Rheology of Complex Fluids*(Oxford University Press, New York, 1999). ISBN 9780195121971S. Peker, S. Helvaci,

*Solid–Liquid Two Phase Flow*(Elsevier Science, 2008). ISBN 9780444522375J. Oldroyd, Proc. R. Soc. Lond. A

**200**, 523 (1950)A. Peterlin, J. Polym. Sci. Part C Polym. Lett.

**4**, 287 (1966)R. Bird, P. Dotson, N. Johnson, J. Nonnewton. Fluid Mech.

**7**, 213 (1980)Y. Zhang, G. Li, A.M. Ardekani, Phys. Rev. Fluids

**3**, 023101 (2018)S. De, J. Kuipers, E. Peters, J. Padding, Phys. Rev. Fluids

**2**, 053303 (2017)L. Zhu, E. Lauga, L. Brandt, Phys. Fluids

**24**, 051902 (2012)G. Li, A.M. Ardekani, Phys. Rev. Lett.

**117**, 118001 (2016)D. Toneian, G. Kahl, G. Gompper, R.G. Winkler, J. Chem. Phys.

**151**, 194110 (2019)S. Sahoo, S.P. Singh, S. Thakur, Soft Matter

**15**, 2170 (2019)B. ten Bosch, J. Nonnewton. Fluid Mech.

**83**, 231 (1999)A. Vázquez-Quesada, P. Español, R.I. Tanner, M. Ellero, J. Fluid Mech.

**880**, 1070 (2019)J. King, S. Lind, arXiv preprint arXiv:2009.12245 (2020)

A.K. Townsend, H.J. Wilson, J. Nonnewton. Fluid Mech.

**261**, 136 (2018)K. Qi, E. Westphal, G. Gompper, R.G. Winkler, Phys. Rev. Lett.

**124**, 068001 (2020)G.R. McNamara, G. Zanetti, Phys. Rev. Lett.

**61**, 2332 (1988)F. Higuera, S. Succi, R. Benzi, Europhys. Lett.

**9**, 345 (1989)T. Krüger, H. Kusumaatmaja, A. Kuzmin, O. Shardt, G. Silva, E.M. Viggen,

*The Lattice Boltzmann Method: Principles and Practice*(Springer, Cham, 2017). ISBN 9783319446479M. Bauer, S. Eibl, C. Godenschwager, N. Kohl, M. Kuron, C. Rettinger, F. Schornbaum, C. Schwarzmeier, D. Thönnes, H. Köstler et al., Comput. Math. Appl. 81, 478 (2021)

Q. Zou, X. He, Phys. Fluids

**9**, 1591 (1997)B. Dünweg, A.J.C. Ladd, in

*Advanced Computer Simulation Approaches for Soft Matter Sciences III*. Vol. 221 of*Advances in Polymer Science*(Springer-Verlag Berlin, Berlin, Germany, 2009), pp. 89–166P. Ahlrichs, B. Dünweg, Int. J. Mod. Phys. C

**9**, 1429 (1998)A.J.C. Ladd, J. Fluid Mech.

**271**, 285 (1994)C.K. Aidun, Y. Lu, E.J. Ding, J. Fluid Mech.

**373**, 287 (1998)L. Giraud, D. d’Humières, P. Lallemand, Int. J. Mod. Phys. C

**8**, 805 (1997)L. Giraud, D. d’Humières, P. Lallemand, Europhys. Lett.

**42**, 625 (1998)I. Ispolatov, M. Grant, Phys. Rev. E

**65**, 056704 (2002)H.B. Li, H.P. Fang, Chin. Phys.

**13**, 2087 (2004)G.N. Frantziskonis, Phys. Rev. E

**83**, 066703 (2011)X. Frank, H.Z. Li, Phys. Rev. E

**71**, 036309 (2005)X. Frank, H.Z. Li, Phys. Rev. E

**74**, 056307 (2006)P.J. Dellar, SIAM J. Sci. Comput.

**36**, A2507 (2014)J. Onishi, Y. Chen, H. Ohashi, Prog. Comput. Fluid Dyn.

**5**, 75 (2005)F. Osmanlic, C. Körner, Comput. Fluids

**124**, 190 (2016)S. Karra, Master’s thesis, Texas A & M University (2007)

J. Su, J. Ouyang, X. Wang, B. Yang, Phys. Rev. E

**88**, 053304 (2013)O. Malaspinas, N. Fiétier, M. Deville, J. Nonnewton. Fluid Mech.

**165**, 1637 (2010)J. Su, J. Ouyang, X. Wang, B. Yang, W. Zhou, J. Nonnewton. Fluid Mech.

**194**, 42 (2013)P.J. Oliveira, F. Pinho, G. Pinto, J. Nonnewton. Fluid Mech.

**79**, 1 (1998)H. Jeffreys,

*The Earth: Its Origin, History and Physical Constitution*(Cambridge University Press, 1976). ISBN 9780521206488R. Bird, R. Armstrong, O. Hassager,

*Dynamics of Polymeric Liquids, Volume 1: Fluid Mechanics*(Wiley, 1987), ISBN 9780471802457H. Giesekus, J. Nonnewton. Fluid Mech.

**11**, 69 (1982)M. Chilcott, J. Rallison, J. Nonnewton. Fluid Mech.

**29**, 381 (1988)N. Phan-Thien, R.I. Tanner, J. Nonnewton. Fluid Mech.

**2**, 353 (1977)M. Deville, T.B. Gatski,

*Mathematical Modeling for Complex Fluids and Flows*(Springer Science & Business Media, 2012), ISBN 9783642435607R. Bird, C. Curtiss, R. Armstrong, O. Hassager,

*Dynamics of Polymeric Liquids, Volume 2: Kinetic Theory*(Wiley-Interscience, 1987), ISBN 9780471802440J. Dealy, Rheol. Bull.

**79**, 14 (2010)I. Ginzburg, F. Verhaeghe, D. d’Humières, Commun. Comput. Phys.

**3**, 427 (2008)Z. Guo, C. Zheng, B. Shi, Phys. Rev. E

**65**, 046308 (2002)U.D. Schiller, Ph.D. thesis, Johannes Gutenberg-Universität Mainz (2008)

U.D. Schiller, Comput. Phys. Commun.

**185**, 2586 (2014)R.B. Bird, J.M. Wiest, Annu. Rev. Fluid Mech.

**27**, 169 (1995)T.N. Phillips, G.W. Roberts, IMA J. Appl. Math.

**76**, 790 (2011)L.N. Carenza, G. Gonnella, A. Lamura, G. Negro, A. Tiribocchi, Eur. Phys. J. E

**42**, 81 (2019)F. Capuani, I. Pagonabarraga, D. Frenkel, J. Chem. Phys.

**121**, 973 (2004)H. Versteeg, W. Malalasekera,

*An Introduction to Computational Fluid Dynamics: The Finite Volume Method*(Pearson Education, 2007), ISBN 9780131274983S. Mazumder,

*Numerical Methods for Partial Differential Equations: Finite Difference and Finite*, vol.*Methods*(Elsevier, 2015). ISBN 9780128035047M. Alves, F. Pinho, P. Oliveira, J. Nonnewton. Fluid Mech.

**97**, 207 (2001)C. Rhie, W.L. Chow, AIAA J.

**21**, 1525 (1983)Ž. Lilek, M. Perić, Comput. Fluids

**24**, 239 (1995)P. Colella, J. Comput. Phys.

**87**, 171 (1990)G. Rempfer, G.B. Davies, C. Holm, J. de Graaf, J. Chem. Phys.

**145**, 044901 (2016)M. Kuron, G. Rempfer, F. Schornbaum, M. Bauer, C. Godenschwager, C. Holm, J. de Graaf, J. Chem. Phys.

**145**, 214102 (2016)N. Rivas, S. Frijters, I. Pagonabarraga, J. Harting, J. Chem. Phys.

**148**, 144101 (2018)C. Godenschwager, F. Schornbaum, M. Bauer, H. Köstler, U. Rüde, A framework for hybrid parallel flow simulations with a trillion cells in complex geometries, in

*Proceedings of the International Conference on High Performance Computing, Networking, Storage and Analysis*(Association for Computing Machinery, 2013), p. 35M. Bauer, J. Hötzer, D. Ernst, J. Hammer, M. Seiz, H. Hierl, J. Hönig, H. Köstler, G. Wellein, B. Nestler et al., Code generation for massively parallel phase-field simulations, in

*Proceedings of the International Conference for High Performance Computing*(Storage and Analysis (Association for Computing Machinery, Networking, 2019), pp. 1–32K.J. Burns, G.M. Vasil, J.S. Oishi, D. Lecoanet, B.P. Brown, Phys. Rev. Res.

**2**, 023068 (2020)H. Jasak, A. Jemcov, Z. Tukovic et al., OpenFOAM: a C++ library for complex physics simulations, in

*International Workshop on Coupled Methods in Numerical Dynamics*(IUC Dubrovnik Croatia, 2007), vol. 1000, pp. 1–20M. Bauer, H. Köstler, U. Rüde, J. Comp. Sci. 49, 101269 (2021)

N. Waters, M. King, Rheol. Acta

**9**, 345 (1970)S.C. Xue, R. Tanner, N. Phan-Thien, J. Nonnewton. Fluid Mech.

**123**, 33 (2004)K.S. Park, Y. don Kwon, Korea Aust. Rheol. J.

**21**, 47 (2009)I. Ginzbourg, P. Adler, J. Phys. II

**4**, 191 (1994)K. Yapici, B. Karasozen, Y. Uludag, J. Nonnewton. Fluid Mech.

**164**, 51 (2009)R. Sousa, R. Poole, A. Afonso, F. Pinho, P. Oliveira, A. Morozov, M. Alves, J. Nonnewton. Fluid Mech.

**234**, 129 (2016)S. Dalal, G. Tomar, P. Dutta, J. Nonnewton. Fluid Mech.

**229**, 59 (2016)T.W. Pan, J. Hao, R. Glowinski, Int. J. Numer. Methods Fluids

**60**, 791 (2009)F. Habla, M.W. Tan, J. Haßlberger, O. Hinrichsen, J. Nonnewton. Fluid Mech.

**212**, 47 (2014)B. Thomases, M. Shelley, Phys. Fluids

**19**, 103103 (2007)F. Pimenta, M. Alves, J. Nonnewton. Fluid Mech.

**239**, 85 (2017)L.P. Fischer, T. Peter, C. Holm, J. de Graaf, J. Chem. Phys.

**143**, 084107 (2015)K.D. Housiadas, Phys. Rev. Fluids

**4**, 103301 (2019)A. Castillo, W.L. Murch, J. Einarsson, B. Mena, E.S. Shaqfeh, R. Zenit, Phys. Rev. Fluids

**4**, 063302 (2019)M. Hütter, P. D. Olmsted, D. J. Read, Eur. Phys. J. E 43, 71 (2020)

W.L. Murch, E.S.G. Shaqfeh, Phys. Rev. Fluids

**5**, 073301 (2020)J.P. Binagia, A. Phoa, K.D. Housiadas, E.S.G. Shaqfeh, J. Fluid Mech.

**900**, A4 (2020)S. Saad, G. Natale, Soft Matter

**15**, 9909 (2019)

## Acknowledgements

We are grateful to Martin Bauer for help with pystencils and thank Ashreya Jayaram, Alexander Morozov, Becca Thomases, and Rudolf Weeber for useful discussions and Fabian Häusl for helpful comments on the manuscript. We acknowledge the Deutsche Forschungsgemeinschaft (DFG) for funding through the SPP 1726 “Microswimmers: from single particle motion to collective behavior” (HO1108/24-2) and through the EXC 2075 “SimTech” (390740016). JdG further acknowledges funding by an NWO START-UP grant (740.018.013).

## Funding

Open Access funding enabled and organized by Projekt DEAL.

## Author information

### Authors and Affiliations

### Contributions

MK and JdG conceptualized the article; MK and CS performed calculations and analysis; MK, CS, and JdG wrote the manuscript; MK, JdG, and CH were involved in supervision; JdG and CH acquired the funding; and CH provided the resources.

### Corresponding author

## Rights and permissions

**Open Access** This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article’s Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.

## About this article

### Cite this article

Kuron, M., Stewart, C., de Graaf, J. *et al.* An extensible lattice Boltzmann method for viscoelastic flows: complex and moving boundaries in Oldroyd-B fluids.
*Eur. Phys. J. E* **44**, 1 (2021). https://doi.org/10.1140/epje/s10189-020-00005-6

Received:

Accepted:

Published:

DOI: https://doi.org/10.1140/epje/s10189-020-00005-6