# The log-conformation method for some viscoelastic constitutive models

## Introduction

Viscoelastic fluids exhibit both viscous and elastic behaviour when subjected to deformation. Therefore these materials are governed by the Navier–Stokes equations enriched with an extra elastic stress ${\mathbf{\text{\tau}}}_{p}$ $\rho \left[{\partial }_{t}\mathbf{\text{u}}+\nabla \cdot \left(\mathbf{\text{u}}\otimes \mathbf{\text{u}}\right)\right]=-\nabla p+\nabla \cdot \left(2{\mu }_{s}\mathbf{\text{D}}\right)+\nabla \cdot {\mathbf{\text{\tau}}}_{p}+\rho \mathbf{\text{a}}$ where $\mathbf{\text{D}}=\left[\nabla \mathbf{\text{u}}+\left(\nabla \mathbf{\text{u}}{\right)}^{T}\right]/2$ is the deformation tensor and ${\mu }_{s}$ is the solvent viscosity of the viscoelastic fluid.

The polymeric stress ${\mathbf{\text{\tau}}}_{p}$ represents memory effects due to the polymers. Several constitutive rheological models are available in the literature where the polymeric stress ${\mathbf{\text{\tau}}}_{p}$ is typically a function $\mathbf{\text{f_s}}\left(\cdot \right)$ of the conformation tensor $\mathbf{\text{A}}$ such as ${\mathbf{\text{\tau}}}_{p}=\frac{{\mu }_{p}\mathbf{\text{f_s}}\left(\mathbf{\text{A}}\right)}{\lambda }$ where $\lambda$ is the relaxation parameter and ${\mu }_{p}$ is the polymeric viscosity.

The conformation tensor $\mathbf{\text{A}}$ is related to the deformation of the polymer chains. $\mathbf{\text{A}}$ is governed by the equation ${D}_{t}\mathbf{\text{A}}-\mathbf{\text{A}}\cdot \nabla \mathbf{\text{u}}-\nabla {\mathbf{\text{u}}}^{T}\cdot \mathbf{\text{A}}=-\frac{\mathbf{\text{f_r}}\left(\mathbf{\text{A}}\right)}{\lambda }$ where ${D}_{t}$ denotes the material derivative and $\mathbf{\text{f_r}}\left(\cdot \right)$ is the relaxation function.

In the case of an Oldroyd-B viscoelastic fluid, ${\mathbf{\text{f}}}_{s}\left(\mathbf{\text{A}}\right)={\mathbf{\text{f}}}_{r}\left(\mathbf{\text{A}}\right)=\mathbf{\text{A}}-\mathbf{\text{I}}$, and the above equations can be combined to avoid the use of $\mathbf{\text{A}}$ ${\mathbf{\text{\tau}}}_{p}+\lambda \left({D}_{t}{\mathbf{\text{\tau}}}_{p}-{\mathbf{\text{\tau}}}_{p}\cdot \nabla \mathbf{\text{u}}-\nabla {\mathbf{\text{u}}}^{T}\cdot {\mathbf{\text{\tau}}}_{p}\right)=2{\mu }_{p}\mathbf{\text{D}}$

Comminal et al. (2015) gathered the functions ${\mathbf{\text{f}}}_{s}\left(\mathbf{\text{A}}\right)$ and ${\mathbf{\text{f}}}_{r}\left(\mathbf{\text{A}}\right)$ for different constitutive models. In the present library we have implemented the Oldroyd-B model and the related FENE-P model for which ${\mathbf{\text{f}}}_{s}\left(\mathbf{\text{A}}\right)={\mathbf{\text{f}}}_{r}\left(\mathbf{\text{A}}\right)=\frac{\mathbf{\text{A}}}{1-Tr\left(\mathbf{\text{A}}\right)/{L}^{2}}-\mathbf{\text{I}}$

## Parameters

The primary parameters are the retardation or relaxation time $\lambda$ and the polymeric viscosity ${\mu }_{p}$. The solvent viscosity ${\mu }_{s}$ is defined in the Navier-Stokes solver.

(const) scalar λ = unity;
(const) scalar mup = unity;

Constitutive models other than Oldroyd-B (the default) are defined through the two functions ${\mathbf{\text{f}}}_{s}\left(\mathbf{\text{A}}\right)$ and ${\mathbf{\text{f}}}_{r}\left(\mathbf{\text{A}}\right)$.

void (* f_s) (double, double *, double *) = NULL;
void (* f_r) (double, double *, double *) = NULL;

## The log conformation approach

The numerical resolution of viscoelastic fluid problems often faces the High-Weissenberg Number Problem. This is a numerical instability appearing when strongly elastic flows create regions of high stress and fine features. This instability poses practical limits to the values of the relaxation time of the viscoelastic fluid, $\lambda$. Fattal & Kupferman (2004, 2005) identified the exponential nature of the solution as the origin of the instability. They proposed to use the logarithm of the conformation tensor $\Psi =\mathrm{log}\phantom{\rule{0.167em}{0ex}}\mathbf{\text{A}}$ rather than the viscoelastic stress tensor to circumvent the instability.

The constitutive equation for the log of the conformation tensor is ${D}_{t}\Psi =\left(\Omega \cdot \Psi -\Psi \cdot \Omega \right)+2\mathbf{\text{B}}+\frac{{e}^{-\Psi }{\mathbf{\text{f}}}_{r}\left({e}^{\Psi }\right)}{\lambda }$ where $\Omega$ and $\mathbf{\text{B}}$ are tensors that result from the decomposition of the transpose of the tensor gradient of the velocity $\left(\nabla \mathbf{\text{u}}{\right)}^{T}=\Omega +\mathbf{\text{B}}+N{\mathbf{\text{A}}}^{-1}$

The antisymmetric tensor $\Omega$ requires only the memory of a scalar in 2D since, $\Omega =\left(\begin{array}{cc}\hfill 0\hfill & \hfill {\Omega }_{12}\hfill \\ \hfill -{\Omega }_{12}\hfill & \hfill 0\hfill \end{array}\right)$ The log-conformation tensor, $\Psi$, is related to the polymeric stress tensor ${\mathbf{\text{\tau}}}_{p}$, by the strain function ${\mathbf{\text{f}}}_{s}\left(\mathbf{\text{A}}\right)$ $\Psi =\mathrm{log}\phantom{\rule{0.167em}{0ex}}\mathbf{\text{A}}\phantom{\rule{1em}{0ex}}\mathrm{\text{and}}\phantom{\rule{1em}{0ex}}{\mathbf{\text{\tau}}}_{p}=\frac{{\mu }_{p}}{\lambda }{\mathbf{\text{f}}}_{s}\left(\mathbf{\text{A}}\right)$ where $Tr$ denotes the trace of the tensor and $L$ is an additional property of the viscoelastic fluid.

We will use the Bell–Collela–Glaz scheme to advect the log-conformation tensor $\Psi$.

#include "bcg.h"


## Variables

The main variable will be the stress tensor ${\mathbf{\text{\tau}}}_{p}$. The trace of the conformation tensor, $\mathbf{\text{A}}$, is often necessary for constitutive viscoelastic models other than Oldroyd-B.

symmetric tensor tau_p[];
#if AXI
scalar tau_qq[];
#endif
(const) scalar trA = zeroc;

event defaults (i = 0) {
if (is_constant (a.x))
a = new face vector;
if (f_s || f_r)
trA = new scalar;

foreach() {
foreach_dimension()
tau_p.x.x[] = 0.;
tau_p.x.y[] = 0.;
#if AXI
tau_qq[] = 0;
#endif
}

## Boundary conditions

By default we set a zero Neumann boundary condition for all the components except if the bottom is an axis of symmetry.

  for (scalar s in {tau_p}) {
s.v.x.i = -1; // just a scalar, not the component of a vector
foreach_dimension() {
s[left] = neumann(0);
s[right] = neumann(0);
}
}
#if AXI
scalar s = tau_p.x.y;
s[bottom] = dirichlet (0.);
#endif
}

event init (i = 0) {
#if AXI
boundary((scalar *){tau_p, tau_qq});
#else
boundary((scalar *){tau_p});
#endif
}

## Numerical Scheme

The first step is to implement a routine to calculate the eigenvalues and eigenvectors of the conformation tensor $\mathbf{\text{A}}$.

These structs ressemble Basilisk vectors and tensors but are just arrays not related to the grid.

typedef struct { double x, y;}   pseudo_v;
typedef struct { pseudo_v x, y;} pseudo_t;

static void diagonalization_2D (pseudo_v * Lambda, pseudo_t * R, pseudo_t * A)
{

The eigenvalues are saved in vector $\Lambda$ computed from the trace and the determinant of the symmetric conformation tensor $\mathbf{\text{A}}$.

  if (sq(A->x.y) < 1e-15) {
R->x.x = R->y.y = 1.;
R->y.x = R->x.y = 0.;
Λ->x = A->x.x; Λ->y = A->y.y;
return;
}

double T = A->x.x + A->y.y; // Trace of the tensor
double D = A->x.x*A->y.y - sq(A->x.y); // Determinant

The eigenvectors, ${\mathbf{\text{v}}}_{i}$ are saved by columns in tensor $\mathbf{\text{R}}=\left({\mathbf{\text{v}}}_{1}\mid {\mathbf{\text{v}}}_{2}\right)$.

  R->x.x = R->x.y = A->x.y;
R->y.x = R->y.y = -A->x.x;
double s = 1.;
for (int i = 0; i < dimension; i++) {
double * ev = (double *) Λ;
ev[i] = T/2 + s*sqrt(sq(T)/4. - D);
s *= -1;
double * Rx = (double *) &R->x;
double * Ry = (double *) &R->y;
Ry[i] += ev[i];
double mod = sqrt(sq(Rx[i]) + sq(Ry[i]));
Rx[i] /= mod;
Ry[i] /= mod;
}
}

The stress tensor depends on previous instants and has to be integrated in time. In the log-conformation scheme the advection of the stress tensor is circumvented, instead the conformation tensor, $\mathbf{\text{A}}$ (or more precisely the related variable $\Psi$) is advanced in time.

In what follows we will adopt a scheme similar to that of Hao & Pan (2007). We use a split scheme, solving successively

1. the upper convective term: ${\partial }_{t}\Psi =2\mathbf{\text{B}}+\left(\Omega \cdot \Psi -\Psi \cdot \Omega \right)$
2. the advection term: ${\partial }_{t}\Psi +\nabla \cdot \left(\Psi \mathbf{\text{u}}\right)=0$
3. the model term (but set in terms of the conformation tensor $\mathbf{\text{A}}$). In an Oldroyd-B viscoelastic fluid, the model is ${\partial }_{t}\mathbf{\text{A}}=-\frac{{\mathbf{\text{f}}}_{r}\left(\mathbf{\text{A}}\right)}{\lambda }$

The implementation below assumes that the values of $\Psi$ and ${\tau }_{p}$ are never needed simultaneously. This means that ${\tau }_{p}$ can be used to store (temporarily) the values of $\Psi$ (i.e. $\Psi$ is just an alias for ${\tau }_{p}$).

event tracer_advection (i++)
{
tensor Ψ = tau_p;
#if AXI
scalar Psiqq = tau_qq;
#endif

### Computation of $\Psi =\mathrm{log}\mathbf{\text{A}}$ and upper convective term

  foreach() {
if (λ[] == 0.) {
foreach_dimension()
Ψ.x.x[] = 0.;
Ψ.x.y[] = 0.;
#if AXI
Psiqq[] = 0.;
#endif
}
else { // lambda[] != 0.

We assume that the stress tensor ${\mathbf{\text{\tau}}}_{p}$ depends on the conformation tensor $\mathbf{\text{A}}$ as follows ${\mathbf{\text{\tau}}}_{p}=\frac{{\mu }_{p}}{\lambda }{f}_{s}\left(\mathbf{\text{A}}\right)=\frac{{\mu }_{p}}{\lambda }\eta \left(\nu \mathbf{\text{A}}-I\right)$ In most of the viscoelastic models, $\nu$ and $\eta$ are nonlinear parameters that depend on the trace of the conformation tensor, $\mathbf{\text{A}}$.

      double η = 1., ν = 1.;
if (f_s)
f_s (trA[], &ν, &η);

double fa = (mup[] != 0 ? λ[]/(mup[]*η) : 0.);

pseudo_t A;
A.x.y = fa*tau_p.x.y[]/ν;
foreach_dimension()
A.x.x = (fa*tau_p.x.x[] + 1.)/ν;

In the axisymmetric case, ${\Psi }_{\theta \theta }=\mathrm{log}{A}_{\theta \theta }$. Therefore ${\Psi }_{\theta \theta }=\mathrm{log}\left[\left(1+fa{\tau }_{{p}_{\theta \theta }}\right)/\nu \right]$.

#if AXI
double Aqq = (1. + fa*tau_qq[])/ν;
Psiqq[] = log (Aqq);
#endif

The conformation tensor is diagonalized through the eigenvector tensor $\mathbf{\text{R}}$ and the eigenvalues diagonal tensor, $\Lambda$.

      pseudo_v Λ;
pseudo_t R;
diagonalization_2D (&Λ, &R, &A);

$\Psi =\mathrm{log}\mathbf{\text{A}}$ is easily obtained after diagonalization, $\Psi =R\cdot \mathrm{log}\left(\Lambda \right)\cdot {R}^{T}$.

      Ψ.x.y[] = R.x.x*R.y.x*log(Λ.x) + R.y.y*R.x.y*log(Λ.y);
foreach_dimension()
Ψ.x.x[] = sq(R.x.x)*log(Λ.x) + sq(R.x.y)*log(Λ.y);

We now compute the upper convective term $2\mathbf{\text{B}}+\left(\Omega \cdot \Psi -\Psi \cdot \Omega \right)$.

The diagonalization will be applied to the velocity gradient $\left(\nabla u{\right)}^{T}$ to obtain the antisymmetric tensor $\Omega$ and the traceless, symmetric tensor, $\mathbf{\text{B}}$. If the conformation tensor is $\mathbf{\text{I}}$, $\Omega =0$ and $\mathbf{\text{B}}=\mathbf{\text{D}}$.

      pseudo_t B;
double OM = 0.;
if (fabs(Λ.x - Λ.y) <= 1e-20) {
B.x.y = (u.y[1,0] - u.y[-1,0] +
u.x[0,1] - u.x[0,-1])/(4.*Δ);
foreach_dimension()
B.x.x = (u.x[1,0] - u.x[-1,0])/(2.*Δ);
}
else {
pseudo_t M;
foreach_dimension() {
M.x.x = (sq(R.x.x)*(u.x[1] - u.x[-1]) +
sq(R.y.x)*(u.y[0,1] - u.y[0,-1]) +
R.x.x*R.y.x*(u.x[0,1] - u.x[0,-1] +
u.y[1] - u.y[-1]))/(2.*Δ);
M.x.y = (R.x.x*R.x.y*(u.x[1] - u.x[-1]) +
R.x.y*R.y.x*(u.y[1] - u.y[-1]) +
R.x.x*R.y.y*(u.x[0,1] - u.x[0,-1]) +
R.y.x*R.y.y*(u.y[0,1] - u.y[0,-1]))/(2.*Δ);
}
double ω = (Λ.y*M.x.y + Λ.x*M.y.x)/(Λ.y - Λ.x);
OM = (R.x.x*R.y.y - R.x.y*R.y.x)*ω;

B.x.y = M.x.x*R.x.x*R.y.x + M.y.y*R.y.y*R.x.y;
foreach_dimension()
B.x.x = M.x.x*sq(R.x.x)+M.y.y*sq(R.x.y);
}

We now advance $\Psi$ in time, adding the upper convective contribution.

      double s = - Ψ.x.y[];
Ψ.x.y[] += dt*(2.*B.x.y + OM*(Ψ.y.y[] - Ψ.x.x[]));
foreach_dimension() {
s *= -1;
Ψ.x.x[] += dt*2.*(B.x.x + s*OM);
}

In the axisymmetric case, the governing equation for ${\Psi }_{\theta \theta }$ only involves that component, ${\Psi }_{\theta \theta }{\mid }_{t}-2{L}_{\theta \theta }=\frac{{\mathbf{\text{f}}}_{r}\left({e}^{-{\Psi }_{\theta \theta }}\right)}{\lambda }$ with ${L}_{\theta \theta }={u}_{y}/y$. Therefore step (a) for ${\Psi }_{\theta \theta }$ is

#if AXI
Psiqq[] += dt*2.*u.y[]/y;
#endif
}
}

### Advection of $\Psi$

We proceed with step (b), the advection of the log of the conformation tensor $\Psi$, but first we apply boundary conditions.

#if AXI
boundary ({Ψ.x.x, Ψ.x.y, Ψ.y.y, Psiqq});
advection ({Ψ.x.x, Ψ.x.y, Ψ.y.y, Psiqq}, uf, dt);
#else
boundary ({Ψ.x.x, Ψ.x.y, Ψ.y.y});
advection ({Ψ.x.x, Ψ.x.y, Ψ.y.y}, uf, dt);
#endif

### Model term

  foreach() {
if (λ[] == 0.) {

If $\lambda =0$ the stress tensor for the polymeric part reduces to that of a Newtonian fluid ${\mathbf{\text{\tau}}}_{p}=2{\mu }_{p}\mathbf{\text{D}}$ with $\mathbf{\text{D}}$ the rate-of-strain tensor. Note that ${\mathbf{\text{\tau}}}_{p}$ is in this case independent of time.

      foreach_dimension()
tau_p.x.x[] = mup[]*(u.x[1,0] - u.x[-1,0])/Δ; // 2*mu*dxu;
tau_p.x.y[] = mup[]*(u.y[1,0] - u.y[-1,0] +
u.x[0,1] - u.x[0,-1])/(2.*Δ); // mu*(dxv+dyu)
#if AXI
tau_qq[] = 2.*mup[]*u.y[]/y;
#endif
}
else { // lambda != 0.

It is time to undo the log-conformation, again by diagonalization, to recover the conformation tensor $\mathbf{\text{A}}$ and to perform step (c).

      pseudo_t A = {{Ψ.x.x[], Ψ.x.y[]}, {Ψ.y.x[], Ψ.y.y[]}}, R;
pseudo_v Λ;
diagonalization_2D (&Λ, &R, &A);
Λ.x = exp(Λ.x), Λ.y = exp(Λ.y);

A.x.y = R.x.x*R.y.x*Λ.x + R.y.y*R.x.y*Λ.y;
foreach_dimension()
A.x.x = sq(R.x.x)*Λ.x + sq(R.x.y)*Λ.y;
#if AXI
double Aqq = exp(Psiqq[]);
#endif

We perform now step (c) by integrating ${\mathbf{\text{A}}}_{t}=-{\mathbf{\text{f}}}_{r}\left(\mathbf{\text{A}}\right)/\lambda$ to obtain ${\mathbf{\text{A}}}^{n+1}$. This step is analytic, ${\int }_{{t}^{n}}^{{t}^{n+1}}\frac{d\mathbf{\text{A}}}{\mathbf{\text{I}}-\nu \mathbf{\text{A}}}=\frac{\eta \phantom{\rule{0.167em}{0ex}}\Delta t}{\lambda }$

      double η = 1., ν = 1.;
if (f_r) {
#if 0 // Set to one if the midstep trace is to be used.
scalar t = trA;
t[] = A.x.x + A.y.y;
#if AXI
t[] += Aqq;
#endif
#endif
f_r (trA[], &ν, &η);
}

double fa = exp(-ν*η*dt/λ[]);

#if AXI
Aqq = (1. - fa)/ν + fa*exp(Psiqq[]);
Psiqq[] = log (Aqq);
#endif

A.x.y *= fa;
foreach_dimension()
A.x.x = (1. - fa)/ν + A.x.x*fa;

The trace at time $n+1$ is also needed for some models.

      if (f_s || f_r) {
scalar t = trA;
t[] = A.x.x + A.y.y;
#if AXI
t[] += Aqq;
#endif
}

Then the stress tensor ${\mathbf{\text{\tau}}}_{p}^{n+1}$ is computed from ${\mathbf{\text{A}}}^{n+1}$ according to the constitutive model, ${\mathbf{\text{f}}}_{s}\left(\mathbf{\text{A}}\right)$.

      ν = 1; η = 1.;
if (f_s)
f_s (trA[], &ν, &η);

fa = mup[]/λ[]*η;

tau_p.x.y[] = fa*ν*A.x.y;
#if AXI
tau_qq[] = fa*(ν*Aqq - 1.);
#endif
foreach_dimension()
tau_p.x.x[] = fa*(ν*A.x.x - 1.);
}
}

#if AXI
boundary((scalar *){tau_p, tau_qq});
#else
boundary((scalar *){tau_p});
#endif
}

### Divergence of the viscoelastic stress tensor

The viscoelastic stress tensor ${\mathbf{\text{\tau}}}_{p}$ is defined at cell centers while the corresponding force (acceleration) will be defined at cell faces. Two terms contribute to each component of the momentum equation. For example the $x$-component in Cartesian coordinates has the following terms: ${\partial }_{x}{\mathbf{\text{\tau}}}_{{p}_{xx}}+{\partial }_{y}{\mathbf{\text{\tau}}}_{{p}_{xy}}$. The first term is easy to compute since it can be calculated directly from center values of cells sharing the face. The other one is harder. It will be computed from vertex values. The vertex values are obtained by averaging centered values. Note that as a result of the vertex averaging cells [] and [-1,0] are not involved in the computation of shear.

event acceleration (i++)
{
face vector av = a;
foreach_face()
if (fm.x[] > 1e-20) {
double shear = (tau_p.x.y[0,1]*cm[0,1] + tau_p.x.y[-1,1]*cm[-1,1] -
tau_p.x.y[0,-1]*cm[0,-1] - tau_p.x.y[-1,-1]*cm[-1,-1])/4.;
av.x[] += (shear + cm[]*tau_p.x.x[] - cm[-1]*tau_p.x.x[-1])*
α.x[]/(sq(fm.x[])*Δ);
}
#if AXI
foreach_face(y)
if (y > 0.)
av.y[] -= (tau_qq[] + tau_qq[0,-1])*α.y[]/sq(y)/2.;
#endif
}

## References

 [comminal2015] Raphaël Comminal, Jon Spangenberg, and Jesper Henri Hattel. Robust simulations of viscoelastic flows at high Weissenberg numbers with the streamfunction/log-conformation formulation. Journal of Non-Newtonian Fluid Mechanics, 223:37-61, 2015. [fattal2004] Raanan Fattal and Raz Kupferman. Constitutive laws for the matrix-logarithm of the conformation tensor. Journal of Non-Newtonian Fluid Mechanics, 123(2-3):281-285, 2004. [fattal2005] Raanan Fattal and Raz Kupferman. Time-dependent simulation of viscoelastic flows at high Weissenberg number using the log-conformation representation. Journal of Non-Newtonian Fluid Mechanics, 126(1):23-37, 2005. [hao2007] Jian Hao and Tsorng-Whay Pan. Simulation for high Weissenberg number: viscoelastic flow by a finite element method. Applied mathematics letters, 20(9):988-993, 2007.