Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Solutions · 2. The high Weissenberg number problem and the log-conformation formulation

Worked solutions to the three exercises of Lecture 2. Each solution is computed here and checked with assert statements against an exact identity or an independent calculation. The first code cell sets up the notebook and runs Demonstration 1 of the lecture without showing its output, because some of the solutions use its variables.

Exercise 1

Problem. Check numerically that the time derivative of exp⁡Ψ(t)\exp\boldsymbol{\Psi}(t), approximated by the central difference exp⁡(Ψ+ϵΨ˙)−exp⁡(Ψ−ϵΨ˙)2ϵ\frac{\exp(\boldsymbol{\Psi} + \epsilon\dot{\boldsymbol{\Psi}}) - \exp(\boldsymbol{\Psi} - \epsilon\dot{\boldsymbol{\Psi}})}{2\epsilon} with Ψ˙=Ψ˙kin+C−1frel(C)\dot{\boldsymbol{\Psi}} = \dot{\boldsymbol{\Psi}}_{\mathrm{kin}} + \mathbf{C}^{-1}\mathbf{f}_{\mathrm{rel}}(\mathbf{C}) from the log-conformation equation, equals the right-hand side LC+CL⊤+frel(C)\mathbf{L}\mathbf{C} + \mathbf{C}\mathbf{L}^\top + \mathbf{f}_{\mathrm{rel}}(\mathbf{C}) of the conformation equation, for the Oldroyd-B, FENE-P and Giesekus models.


Exercise 1: the log-conformation equation against the conformation equation
===========================================================================
Oldroyd-B    | ||[C, f_rel]||_F = 1.26e-15 | ||d/dt exp(Psi) - dC/dt||_F = 1.072e-09
FENE-P       | ||[C, f_rel]||_F = 0.00e+00 | ||d/dt exp(Psi) - dC/dt||_F = 3.130e-10
Giesekus     | ||[C, f_rel]||_F = 7.02e-16 | ||d/dt exp(Psi) - dC/dt||_F = 1.596e-09
<Figure size 748x385 with 1 Axes>

Figure S2.1. Frobenius norm of the difference between the time derivative of exp⁡Ψ\exp\boldsymbol{\Psi}, by finite differences, and C˙\dot{\mathbf{C}} from the conformation equation, for three models. The values are of the size of the finite-difference error.

Explanation. The derivative of exp⁡Ψ\exp\boldsymbol{\Psi} equals CΨ˙\mathbf{C}\dot{\boldsymbol{\Psi}} only when Ψ˙\dot{\boldsymbol{\Psi}} commutes with Ψ\boldsymbol{\Psi}. The log-conformation equation splits Ψ˙\dot{\boldsymbol{\Psi}} into a rotation of the principal axes, [Ω,Ψ][\boldsymbol{\Omega}, \boldsymbol{\Psi}], whose effect on C\mathbf{C} is [Ω,C][\boldsymbol{\Omega}, \mathbf{C}], and the terms 2B+C−1frel(C)2\mathbf{B} + \mathbf{C}^{-1}\mathbf{f}_{\mathrm{rel}}(\mathbf{C}), which commute with Ψ\boldsymbol{\Psi} because frel\mathbf{f}_{\mathrm{rel}} is an isotropic function of C\mathbf{C} (the commutator [C,frel][\mathbf{C}, \mathbf{f}_{\mathrm{rel}}] is zero to 10-15 in the output). The two right-hand sides agree to between 3×10−103\times10^{-10} and 2×10−92\times10^{-9} for the three models; differences of this size are expected from the central difference itself.


Exercise 2

Problem. Compare the methods direct_euler and log_psi in a uniaxial extension that reverses: lam = 0.22, L=diag⁡(2.5,−1.25,−1.25)\mathbf{L} = \operatorname{diag}(2.5, -1.25, -1.25) for t<1t < 1 and -1.8 times this tensor for t≥1t \ge 1, on the grid np.linspace(0.0, 3.0, 7), which has a step of 0.50. Record the smallest and the largest eigenvalue and the determinant of C\mathbf{C} at each step, and then reduce the step to find where direct_euler becomes stable.


Exercise 2: loss of positive definiteness after a reversal of the flow
======================================================================
Coarse dt=0.50 -> direct_euler min_eig = -35.644 (diverged: True)
Coarse dt=0.50 -> log_psi      min_eig = 0.3386 (diverged: False)
<Figure size 1122x407 with 2 Axes>

Figure S2.2. (a) Smallest eigenvalue of C\mathbf{C} for the fine reference, the coarse log-conformation run and the coarse direct Euler run (values below -35 are clipped in the plot). (b) Smallest determinant over the run against Δt/λ\Delta t/\lambda, clipped at -2: the direct Euler update stays positive definite up to Δt/λ=0.27\Delta t/\lambda = 0.27 and fails from 0.36 on.

Explanation. The explicit update of a diagonal component is Ciin+1=Ciin[1+(2Lii−1/λ)Δt]+Δt/λC_{ii}^{n+1} = C_{ii}^n[1 + (2L_{ii} - 1/\lambda)\Delta t] + \Delta t/\lambda. After the reversal Lxx=−4.5L_{xx} = -4.5, and with Δt=0.50\Delta t = 0.50 the factor in brackets is 1+(−9−4.55)×0.5=−5.81 + (-9 - 4.55)\times 0.5 = -5.8. The large value of CxxC_{xx} built up during the stretch therefore becomes negative in one step, and the smallest eigenvalue reaches -35.6. In the logarithmic variable the same compression lowers Ψxx\Psi_{xx}, and eΨxxe^{\Psi_{xx}} stays positive: the smallest eigenvalue is 0.34. When the step is reduced, the direct update stays positive definite up to Δt/λ=0.27\Delta t/\lambda = 0.27 (Δt=0.06\Delta t = 0.06); at Δt/λ=0.36\Delta t/\lambda = 0.36 the determinant is already negative (Figure S2.2b).


Exercise 3

Problem. Write a second-order Runge–Kutta solver of the log-conformation equation in NumPy for the FENE-P model (λ=0.75 s\lambda = 0.75\ \mathrm{s}, ηp=1.5 Pa⋅s\eta_p = 1.5\ \mathrm{Pa\cdot s}, b=45b = 45) in a three-dimensional flow with Lxy(t)=6sin⁡(πt/2)L_{xy}(t) = 6\sin(\pi t/2), Lxx=−0.8L_{xx} = -0.8, Lyy=0.3L_{yy} = 0.3, Lzz=0.5L_{zz} = 0.5 for 0≤t≤2.0 s0 \le t \le 2.0\ \mathrm{s}, and compare the conformation tensors with those of tensors_kinematics.integrate_homogeneous_constitutive.


Exercise 3: a log-conformation solver for the FENE-P model in three dimensions
==============================================================================
Max |C_scratch - C_engcomprheo| across all 101 3x3 tensors: 0.000e+00
Minimum det(C) during 3-D mixed flow                      : 1.0000 > 0
<Figure size 1122x407 with 2 Axes>

Figure S2.3. Three-dimensional FENE-P model in a mixed flow, integrated with a separate log-conformation code. (a) Two components against the package. (b) The three eigenvalues, all positive.

Explanation. The solver needs one symmetric eigenvalue problem (np.linalg.eigh) for each stage, uses the limit of the off-diagonal formula when two eigenvalues are equal, and returns C=exp⁡Ψ\mathbf{C} = \exp\boldsymbol{\Psi} with positive eigenvalues for any velocity gradient. It reproduces the result of the package exactly (the difference over the 101 tensors is zero), and the smallest determinant during the flow is 1.0000, the value at the start. The same step is applied in every cell of the two-dimensional solver of Lectures 13, 14 and 17.