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,

$$\begin{aligned} \sum \limits _{k=1}^d\frac{\partial }{\partial r_k}\sigma _{ki}(\varvec{r},t)&=-F^\text {ext}_i(\varvec{r},t), \end{aligned}$$
(1)
$$\begin{aligned} \sum \limits _{k=1}^d\frac{\partial }{\partial r_k}u_k(\varvec{r},t)&=0. \end{aligned}$$
(2)

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:

$$\begin{aligned} \sigma _{ij}(\varvec{r},t)&=\varepsilon _{ij}(\varvec{r},t)-p(\varvec{r},t)\delta _{ij}, \end{aligned}$$
(3)
$$\begin{aligned} \varepsilon _{ij}(\varvec{r},t)&=\eta _\text {n}\left( \frac{\partial }{\partial r_i}u_j(\varvec{r},t)+\frac{\partial }{\partial r_j}u_i(\varvec{r},t)\right) , \end{aligned}$$
(4)

which simplifies Eq. (1) to

$$\begin{aligned} \eta _\text {n}\sum \limits _{k=1}^d\frac{\partial ^2}{\partial r_k^2}u_i(\varvec{r},t)&=\frac{\partial }{\partial r_i} p(\varvec{r})-F^\text {ext}_i(\varvec{r},t). \end{aligned}$$
(5)

\(\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

$$\begin{aligned} \varvec{F}^\text {p}(\varvec{r},t)=\sum \limits _{j=1}^d \hat{\varvec{e}}_j \sum \limits _{i=1}^d \frac{\partial }{\partial r_i} \tau _{ij}(\varvec{r},t), \end{aligned}$$
(6)

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:

$$\begin{aligned} \frac{\partial }{\partial t} \tau _{ij}(\varvec{r},t)&= -\sum _{k=1}^d u_k(\varvec{r},t)\frac{\partial }{\partial r_k} \tau _{ij}(\varvec{r},t) \nonumber \\&\quad + \sum \limits _{k=1}^d \tau _{ik}(\varvec{r},t) \frac{\partial }{\partial r_k} u_j(\varvec{r},t) \nonumber \\&\quad + \sum \limits _{k=1}^d \tau _{kj}(\varvec{r},t) \frac{\partial }{\partial r_k} u_i(\varvec{r},t) \nonumber \\&\quad +\frac{\eta _\text {p}}{\lambda _\text {p}}\left( \frac{\partial }{\partial r_i}u_j(\varvec{r},t) + \frac{\partial }{\partial r_j}u_i(\varvec{r},t)\right) \nonumber \\&\quad - \frac{1}{\lambda _\text {p}}\tau _{ij}(\varvec{r},t) . \end{aligned}$$
(7)

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:

$$\begin{aligned} \frac{\partial }{\partial t}\tau _{ij}(\varvec{r},t)&= -\frac{\partial }{\partial r_k} J_{ijk}(\varvec{r},t) + S_{ij}(\varvec{r},t) \end{aligned}$$
(8)
$$\begin{aligned} J_{ijk}(\varvec{r},t)&= u_k(\varvec{r},t)\tau _{ij}(\varvec{r},t) \end{aligned}$$
(9)
$$\begin{aligned} S_{ij}(\varvec{r},t)&= \tau _{ij}(\varvec{r},t)\underbrace{\sum _{k=1}^d\frac{\partial }{\partial r_k} u_k(\varvec{r},t)}_{=0 \text { per Eq. }(2)} \nonumber \\&\quad + \sum \limits _{k=1}^d \tau _{ik}(\varvec{r},t) \frac{\partial }{\partial r_k} u_j(\varvec{r},t) \nonumber \\&\quad + \sum \limits _{k=1}^d \tau _{kj}(\varvec{r},t) \frac{\partial }{\partial r_k} u_i(\varvec{r},t) \nonumber \\&\quad +\frac{\eta _\text {p}}{\lambda _\text {p}}\left( \frac{\partial }{\partial r_i}u_j(\varvec{r},t) + \frac{\partial }{\partial r_j}u_i(\varvec{r},t)\right) \nonumber \\&\quad - \frac{1}{\lambda _\text {p}}\tau _{ij}(\varvec{r},t). \end{aligned}$$
(10)

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:

$$\begin{aligned} \mathrm {Re}=\frac{\rho U L}{\eta }, \end{aligned}$$
(11)

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]:

$$\begin{aligned} \mathrm {De}=\frac{\lambda _\text {p}U}{L}, \end{aligned}$$
(12)

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]:

$$\begin{aligned} \mathrm {Wi}=\lambda _\text {p}{\dot{\gamma }}. \end{aligned}$$
(13)

Finally, it is convenient to introduce the polymer viscosity fraction

$$\begin{aligned} \beta =\frac{\eta _\text {p}}{\eta }, \end{aligned}$$
(14)

which can easily be varied while keeping the total viscosity

$$\begin{aligned} \eta =\eta _\text {n}+\eta _\text {p} \end{aligned}$$
(15)

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 DdQq 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

$$\begin{aligned} f_i(\varvec{r}+\varvec{c}_i\Delta t,t+\Delta t)&=f_i(\varvec{r},t) \nonumber \\&\quad -\lambda _+\left( f_i^+(\varvec{r},t)-f_i^{\text {eq}+}(\varvec{r},t)\right) \nonumber \\&\quad -\lambda _-\left( f_i^-(\varvec{r},t)-f_i^{\text {eq}-}(\varvec{r},t)\right) \nonumber \\&\quad +\Delta _i (\varvec{r},t) \end{aligned}$$
(16)

with

$$\begin{aligned} f_i^{\pm }(\varvec{r},t)&= \frac{1}{2} \left( f_i(\varvec{r},t) \pm f_{-i}(\varvec{r},t) \right) , \end{aligned}$$
(17)
$$\begin{aligned} f_i^{\text {eq}\pm }(\varvec{r},t)&= \frac{1}{2} \left( f_i^\text {eq}(\varvec{r},t) \pm f_{-i}^\text {eq}(\varvec{r},t) \right) , \end{aligned}$$
(18)
$$\begin{aligned} f_i^\text {eq}(\varvec{r},t)&= w_i\rho (\varvec{r},t) \left( 1 + 3\varvec{c}_i\cdot \varvec{u}(\varvec{r},t) \right. \nonumber \\&\quad \left. + \frac{1}{6}\left( \varvec{c}_i\cdot \varvec{u}(\varvec{r},t)\right) ^2 -\frac{1}{6}u(\varvec{r},t)^2 \right) , \end{aligned}$$
(19)
$$\begin{aligned} \eta _\text {n}&= \rho (\varvec{r},t)\left( \frac{1}{3\lambda _+}-\frac{1}{6}\right) , \end{aligned}$$
(20)
$$\begin{aligned} \lambda _-&=\frac{3}{16\lambda _+}, \end{aligned}$$
(21)

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

$$\begin{aligned} \rho (\varvec{r},t)&=\sum \limits _{i=1}^q f_i(\varvec{r},t), \end{aligned}$$
(22)
$$\begin{aligned} \varvec{u}(\varvec{r},t)&=\frac{1}{\rho (\varvec{r},t)}\sum \limits _{i=1}^q f_i(\varvec{r},t)\varvec{c}_i +\frac{1}{2}\varvec{F}^\text {ext}(\varvec{r},t) \Delta t . \end{aligned}$$
(23)

\(\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]:

(24)

with

(25)

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

$$\begin{aligned} f_i(\varvec{r}_\text {b}+\varvec{c}_i\Delta t,t+\Delta t) \equiv f_{-i}(\varvec{r}_\text {b},t) + \frac{6\rho w_i\Delta t^2}{\Delta x^2} \varvec{c}_i\cdot \varvec{u}_\text {b},\nonumber \\ \end{aligned}$$
(26)

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

$$\begin{aligned} \frac{\partial }{\partial t} {\bar{\tau }}_{ij}(\varvec{r},t)&= -\frac{1}{V}\int _V\sum \limits _{k=1}^{d}\frac{\partial }{\partial r_k}J_{ijk}(\varvec{r},t)\mathrm {d}V+{\bar{S}}_{ij}(\varvec{r},t) \nonumber \\&= -\frac{1}{V}\int _{\partial V}\sum \limits _{k=1}^{d}J_{ijk}(\varvec{r},t)n_k\mathrm {d}S+{\bar{S}}_{ij}(\varvec{r},t), \end{aligned}$$
(27)

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

$$\begin{aligned} {\bar{\tau }}_{ij}(\varvec{r},t+\Delta t)&\approx -\frac{1}{V}\sum \limits _{\ell =1}^q \sum \limits _{k=1}^{d} J_{ijk}(\varvec{r}+\frac{1}{2}\varvec{c}_\ell \Delta t,t)c_{\ell k} \nonumber \\&\quad +{\bar{S}}_{ij}(\varvec{r},t) + {\bar{\tau }}_{ij}(\varvec{r},t), \end{aligned}$$
(28)

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

$$\begin{aligned} Z(\varvec{r}+\frac{1}{2}\varvec{c}_i\Delta t,t)&\approx \frac{1}{2}\left( Z(\varvec{r},t) + Z(\varvec{r}+\varvec{c}_i\Delta t,t)\right) \end{aligned}$$
(29)

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

(30)

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

$$\begin{aligned} A_0=\frac{1}{2d}\sum \limits _{\ell =1}^q \left| c_\ell \right| . \end{aligned}$$
(31)

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:

$$\begin{aligned} \int _V\frac{\partial }{\partial r_i}\varvec{u}(\varvec{r},t) \mathrm {d}V&= \int \limits _{-\Delta x/2}^{\Delta x/2} \cdots \int \limits _{-\Delta x/2}^{\Delta x/2} \left( \varvec{u}(\varvec{r}+\frac{\Delta x}{2}\hat{\varvec{e}}_i,t)\right. \nonumber \\&\quad \left. -\varvec{u}(\varvec{r}-\frac{\Delta x}{2}\hat{\varvec{e}}_i,t)\right) \frac{\mathrm {d}r_1\cdots \mathrm {d}r_d}{\mathrm {d}r_i} . \end{aligned}$$
(32)

Making the central-point approximation

$$\begin{aligned} \int \limits _{-\Delta x/2}^{\Delta x/2} \cdots \int \limits _{-\Delta x/2}^{\Delta x/2}&\varvec{u}(\varvec{r}\pm \frac{\Delta x}{2}\hat{\varvec{e}}_i,t) \frac{\mathrm {d}r_1\cdots \mathrm {d}r_d}{\mathrm {d}r_i} \nonumber \\&\approx \Delta x^{d-1} \varvec{u}(\varvec{r}\pm \frac{\Delta x}{2}\hat{\varvec{e}}_i,t) \end{aligned}$$
(33)

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

$$\begin{aligned} \frac{\partial }{\partial r_i}\varvec{u}(\varvec{r},t)\approx \frac{1}{2\Delta x}\left( \varvec{u}(\varvec{r}+\hat{\varvec{e}}_i,t)-\varvec{u}(\varvec{r}-\hat{\varvec{e}}_i,t)\right) ,\nonumber \\ \end{aligned}$$
(34)

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:

$$\begin{aligned} F^\text {p}_j(\varvec{r},t)&= \frac{1}{V}\int _V\sum \limits _{i=1}^d \frac{\partial }{\partial r_i} \tau _{ij}(\varvec{r},t) \mathrm {d}V \nonumber \\&= \frac{1}{V}\int _{\partial V}\sum \limits _{i=1}^d \tau _{ij}(\varvec{r},t) n_i \mathrm {d}S \end{aligned}$$
(35)
$$\begin{aligned}&\approx \frac{1}{A_0}\sum \limits _{\ell =1}^q\frac{1}{\left| c_\ell \right| }\sum \limits _{i=1}^d \tau _{ij}(\varvec{r}+\frac{1}{2}\varvec{c}_\ell \Delta t,t) c_{\ell i}, \end{aligned}$$
(36)

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

(37)

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

(38)

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

$$\begin{aligned} \varvec{u}_\text {b}(\varvec{r}_\text {b},t)=\varvec{v}(t)+\varvec{\omega }(t)\times (\varvec{r}_\text {b}-\varvec{r}(t)), \end{aligned}$$
(39)

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

$$\begin{aligned} \varvec{F}(t)&=V \sum \limits _{i=1}^{q} \varvec{c}_i \left( f_i(\varvec{r}_\text {b},t)+f_{-i}(\varvec{r}_\text {b}+\varvec{c}_i\Delta t,t)\right) , \end{aligned}$$
(40)
$$\begin{aligned} \varvec{T}(t)&=V \sum \limits _{i=1}^{q} \left( \varvec{r}_\text {b}-\varvec{r}\right) \times \varvec{c}_i \left( f_i(\varvec{r}_\text {b},t)+f_{-i}(\varvec{r}_\text {b}+\varvec{c}_i\Delta t,t)\right) . \end{aligned}$$
(41)

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:

$$\begin{aligned} \varvec{F}(t)=\pm \frac{V}{\Delta t}\rho (\varvec{r}_\text {f},t)\varvec{u}(\varvec{r}_\text {f},t). \end{aligned}$$
(42)

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

(43)

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

(44)

and the corresponding amount is removed from the neighboring cells:

(45)

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].

Fig. 1
figure 1

Geometry of the planar Poiseuille flow system. A force F is applied to a fluid in a periodic channel of width L, which leads to a parabolic profile across the channel for the flow velocity \(u_x\) along the channel. The dashed line indicates where the flow velocity is measured for further analysis

Fig. 2
figure 2

Velocity at the center of a planar Poiseuille channel over time for varying viscosity ratios \(\beta \) and polymer relaxation time \(\lambda _\text {p}=3000\Delta t\). Symbols are numerical calculations, and lines show the analytical prediction by Ref. [77]. The solid lines use L from the input parameters, whereas the dashed lines allow it to be a free fit parameter

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

$$\begin{aligned} \mathrm {Re} =\frac{\rho u_x((x,L/2)^\intercal ,\infty )L}{\eta } =\frac{\rho F_xL^3}{8\eta ^2} = 0.03, \end{aligned}$$
(46)

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.

Fig. 3
figure 3

Velocity at the center of a planar Poiseuille channel over time for viscosity ratio \(\beta =0.3\) and varying polymer relaxation times \(\lambda _\text {p}\). Symbols are numerical calculations, and lines show the analytical prediction by Ref. [77]. The solid lines use L from the input parameters, whereas the dashed lines allow it to be a free fit parameter

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,

$$\begin{aligned} N_1=\tau _{xx}-\tau _{yy}=2\eta _\text {p}\lambda _\text {p}\frac{u_0^2}{L^2}, \end{aligned}$$
(47)

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).

Fig. 4
figure 4

Geometry of the planar Couette flow system. A velocity boundary condition of \(u_0\) is applied to one side of a fluid in a periodic channel of width L, which leads to a linear profile across the channel for the flow velocity \(u_x\) along the channel

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.

Fig. 5
figure 5

Geometry of the lid-driven cavity system. A square flow cell of size L has no-slip boundaries on three sides and a constant-velocity boundary condition of \(u_0\) along the fourth. The resulting flow develops a primary vortex near the top middle of the cell. Along the dashed lines, flow velocity minima and maxima are found at the red crosses. The blue arrow indicates how the vortex center moves as \(\mathrm {Wi}\) is increased from 0 to 1

Fig. 6
figure 6

Positions of the primary vortex and flow extrema in the lid-driven cavity. Colors refer to the different points. Symbols are our results, while the hatched areas indicates the range covered by the numerical results from Refs. [82,83,84,85]

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]

$$\begin{aligned} \mathrm {Wi}=\mathrm {De}=\frac{\lambda _\text {p}u_0}{L} \end{aligned}$$
(48)

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

$$\begin{aligned} \mathrm {Re}=\frac{\rho u_0L}{\eta } = 0.02, \end{aligned}$$
(49)

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

$$\begin{aligned} \varvec{u}((x,L)^\intercal ,t)=16u_0\left( \frac{x}{L}\right) ^2\left( 1-\frac{x}{L}\right) ^2\hat{\varvec{e}}_x. \end{aligned}$$
(50)

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.

Fig. 7
figure 7

Velocity of the flow extrema in the lid-driven cavity. Colors refer to the different points. Symbols are our results, while the line refers to numerical results from Ref. [85]. The square symbols indicate Newtonian simulations (\(\beta \rightarrow 0\)) and match results from Ref. [82], while the others are viscoelastic (\(\beta =0.5\))

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

$$\begin{aligned} \varvec{F}(\varvec{r},t)=\frac{8\pi ^2\eta _\text {n}u_0}{L^2} \begin{pmatrix} \sin \left( \frac{2\pi }{L}x\right) \cos \left( \frac{2\pi }{L}y\right) \\ \cos \left( \frac{2\pi }{L}x\right) \sin \left( \frac{2\pi }{L}y\right) \end{pmatrix} \end{aligned}$$
(51)

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)\).

Fig. 8
figure 8

Geometry of the four-roll mill. Four counter-rotating forces F are applied to a periodic square flow cell of size L. This leads to a pure extensional flow at the center of the cell. Velocity and stress will be measured along the dashed line. The dotted square indicates the actual simulation domain used, which still obeys the periodic boundary conditions

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]

$$\begin{aligned} \mathrm {Wi}=\frac{4\pi \lambda _\text {p}u_0}{L}, \end{aligned}$$
(52)

and the Reynolds number is low at

$$\begin{aligned} \mathrm {Re}=\frac{\rho u_0L}{\eta }=0.1. \end{aligned}$$
(53)

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.

Fig. 9
figure 9

ad Stress \(\tau _{xx}((L/2,y)^\intercal ,\infty )\) near the center of the four-roll mill for different polymer relaxation times \(\lambda _\text {p}\). Symbols are our results, with their connecting line coming from fitting Eq. (54) with an added offset. The other lines are fits with Eq. (54) via one or two parameters. e \(\mathrm {Wi}_\text {eff}\) plotted over the Weissenberg number \(\mathrm {Wi}\). Symbols are our results, while the line comes from Ref. [86]

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,

$$\begin{aligned} \tau _{xx}((L/2,y)^\intercal ,\infty )= & {} \frac{2\eta _\text {p}\mathrm {Wi}_\text {eff}}{\lambda _\text {p}(1-2\mathrm {Wi}_\text {eff})}\nonumber \\&+\, C\left| \frac{y}{L}-\frac{1}{2}\right| ^{\frac{1-2\mathrm {Wi}_\text {eff}}{\mathrm {Wi}_\text {eff}}}. \end{aligned}$$
(54)

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.

Fig. 10
figure 10

Geometry of the sedimenting sphere system. A sphere of radius R sediments under velocity v due to an applied force F in a periodic cubic box of length L. A torque M is applied to the sphere to rotate it with velocity \(\omega \)

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,

$$\begin{aligned} v_\text {Stokes}&= \frac{F}{6\pi \eta R}, \end{aligned}$$
(55)

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

$$\begin{aligned} \mathrm {Re}&=\frac{2\rho v_\text {Stokes}R}{\eta } =\frac{\rho F}{3\pi \eta ^2} \in [0.003,0.03], \end{aligned}$$
(56)

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

$$\begin{aligned} \mathrm {Wi}&= \lambda _\text {p} \omega _z \end{aligned}$$
(57)
$$\begin{aligned} \mathrm {De}&= \frac{\lambda _\text {p} v_0}{R}, \end{aligned}$$
(58)

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

$$\begin{aligned} \mathrm {Re}_\text {t,max}&=\frac{2\rho v_\text {t,max}R}{\eta } \equiv 0.1, \end{aligned}$$
(59)

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

$$\begin{aligned} \mathrm {Wi}_\text {max}&=\lambda _\text {p}\omega _\text {max} =\frac{\lambda _\text {p} \mathrm {Re}_\text {t,max}\eta }{2\rho R^2}. \end{aligned}$$
(60)
Fig. 11
figure 11

Sedimentation velocity of a rotating sphere in an Oldroyd-B fluid. Symbols with error bars are our results, while the lines are theoretical predictions from Ref. [89] for the same parameters (ending at \(\mathrm {Wi}_\text {max}\) as per Eq. (60)). The inset displays an enlargement of the lower left region of the large graph indicated by the dotted box

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.