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 · 4. The Kramers stress and variance reduction with control variates

Worked solutions to the three exercises of Lecture 4. 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 by radial quadrature that for a FENE dumbbell with b=15b = 15, although ⟨Q2⟩eq=3bb+5=2.25\langle Q^2\rangle_{\mathrm{eq}} = \frac{3b}{b+5} = 2.25 is smaller than 3, the mean ⟨Q⋅F(Q)⟩eq\langle \mathbf{Q}\cdot\mathbf{F}(\mathbf{Q})\rangle_{\mathrm{eq}} equals 3 (that is, ⟨QiFj⟩eq=δij\langle Q_i F_j\rangle_{\mathrm{eq}} = \delta_{ij}), so that the Kramers expression gives zero polymer stress at rest. Repeat for other values of bb.


Exercise 1: the equilibrium mean of Q.F for the FENE spring
===========================================================
At b = 15: <Q^2>_eq = 2.250000 (< 3.0), yet <Q . F(Q)>_eq = 3.00000000 == 3.0
Max |<Q . F>_eq - 3| across all b: 2.309e-14
<Figure size 792x407 with 1 Axes>

Figure S4.1. Equilibrium averages of the FENE dumbbell against bb, by quadrature: ⟨Q⋅F⟩eq=3\langle\mathbf{Q}\cdot\mathbf{F}\rangle_{\mathrm{eq}} = 3 for every bb, while ⟨Q2⟩eq=3b/(b+5)\langle Q^2\rangle_{\mathrm{eq}} = 3b/(b+5) is below 3.

Explanation. Integration by parts gives ∫Qi∂U∂Qje−U d3Q=δij∫e−U d3Q\int Q_i \frac{\partial U}{\partial Q_j} e^{-U}\,d^3\mathbf{Q} = \delta_{ij}\int e^{-U}\,d^3\mathbf{Q} whenever e−Ue^{-U} vanishes on the boundary, as (1−Q2/b)b/2(1 - Q^2/b)^{b/2} does at Q=bQ = \sqrt{b}. Finite extensibility reduces ⟨Q2⟩eq\langle Q^2\rangle_{\mathrm{eq}}, and the larger spring force compensates exactly: the quadrature gives 3.00000000 at b=15b = 15 and differs from 3 by at most 2×10−142\times10^{-14} for the other values of bb. The result holds for any spring law, which is why the isotropic term of the Kramers expression is −I-\mathbf{I} for all of them.


Exercise 2

Problem. Show the effect of a control variate that is not driven by the same random numbers as the simulation. At Wi=0.08\mathrm{Wi} = 0.08, b=40b = 40 and 1500 trajectories compare (1) the FENE simulation alone (seed=12), (2) the Hookean control variate with the same random numbers (seed=12), and (3) an estimator that subtracts an independent Hookean simulation (seed=99) and adds the exact Hookean result Cdet,xy(t)C_{\mathrm{det},xy}(t). Compute the variance reduction factor of (2) and of (3).


Exercise 2: a control variate with independent random numbers
=============================================================
Estimator VRF -> same random numbers: 89.2x | independent random numbers: 0.528x (1.89 times the variance)
Detrended fluctuation variance -> raw: 1.887e-04, independent random numbers: 3.425e-04, control variate: 3.792e-06
<Figure size 1122x407 with 2 Axes>

Figure S4.2. (a) Shear stress from the raw estimate, from a control variate driven by the same random numbers, and from one driven by independent random numbers. (b) Variance reduction factor: 89 with the same random numbers, 0.53 with independent ones.

Explanation. For a weight of 1, Var⁡(X−Y)=Var⁡(X)+Var⁡(Y)−2Cov⁡(X,Y)\operatorname{Var}(X - Y) = \operatorname{Var}(X) + \operatorname{Var}(Y) - 2\operatorname{Cov}(X, Y). With independent random numbers the covariance is zero and the variances add: the variance is 1.9 times that of the simulation alone (a reduction factor of 0.53), at twice the cost. With the same random numbers the variance falls by a factor of 89. The function simulate_dumbbell_bd computes the weight as Cov(raw, cv) / Var(cv), which tends to zero when the two simulations are uncorrelated, so the estimator of the package does not increase the variance in that case.


Exercise 3

Problem. Use the control variate (model="fene", b_ext=80, n_trajectories=1600) to simulate small-amplitude oscillatory shear, γ˙(t)=γ0ωcos⁡(ωt)\dot{\gamma}(t) = \gamma_0\omega\cos(\omega t) with γ0=0.08\gamma_0 = 0.08 and ω∈{0.4,1.0,2.5}\omega \in \{0.4, 1.0, 2.5\}. Obtain G′(ω)G'(\omega) and G′′(ω)G''(\omega) by projecting the stress of the steady cycles on sin⁡(ωt)\sin(\omega t) and cos⁡(ωt)\cos(\omega t), and compare them with the Maxwell moduli Geff(ωλeff)21+(ωλeff)2G_{\mathrm{eff}}\frac{(\omega\lambda_{\mathrm{eff}})^2}{1 + (\omega\lambda_{\mathrm{eff}})^2} and Geffωλeff1+(ωλeff)2G_{\mathrm{eff}}\frac{\omega\lambda_{\mathrm{eff}}}{1 + (\omega\lambda_{\mathrm{eff}})^2} of a Hookean dumbbell with effective constants.


Exercise 3: storage and loss moduli from oscillatory shear with a control variate
=================================================================================
SAOS moduli error sum |Delta G'| + |Delta G''| -> control variate: 0.0292 against, without it, 0.2165
<Figure size 814x418 with 1 Axes>

Figure S4.3. Storage and loss moduli of FENE dumbbells (b=80b = 80) from oscillatory shear of amplitude 0.08 with the control variate (filled symbols), against the single-mode Maxwell curves; crosses are the raw estimate of G′G'.

Explanation. At a strain amplitude of 0.08 the shear stress is small compared with its statistical error, and the moduli from the simulation alone scatter around the Maxwell curves. With the control variate the summed error of G′G' and G′′G'' over the three frequencies is 0.029, against 0.217 without it. The same idea, one set of random numbers shared by two calculations, is used by the Brownian configuration fields of Lecture 12, where the random numbers are shared by all positions in the flow.