A polymer molecule has many relaxation times. Rouse (1953) modelled it as beads joined by springs, each bead with its own friction; the longest relaxation time then grows as with the number of beads. In a dilute solution the motion of one bead also moves the solvent around the other beads (hydrodynamic interaction). Zimm (1956) included this effect in a pre-averaged form and found a longest relaxation time that grows as .
A simulation with hydrodynamic interaction needs a square root of the mobility matrix of the beads. With the Oseen tensor, which treats the beads as points, this matrix is not positive definite when two beads are closer than 1.5 radii, and the square root does not exist. The Rotne–Prager–Yamakawa tensor is positive definite at all distances. This lecture computes the Rouse and Zimm relaxation times, builds the mobility matrix, and simulates chains in shear.
Learning objectives¶
Derive the Rouse relaxation times and compare their dependence on with that of the Zimm relaxation times (
brownian_chains.simulate_rouse_zimm_chain_bd).Assemble the Rotne–Prager–Yamakawa mobility with
brownian_chains.rpy_mobility_tensor, and check its continuity at and its positive eigenvalues.Show where the Oseen mobility (
oseen_unsafe=True) loses positive definiteness.Compute and of Rouse and Zimm chains and compare their slopes with the limits and .
Time: about 60 min
try: # use the installed package, or the copy in this repository
import engcomprheo
except ImportError:
import pathlib, subprocess, sys
for _root in [pathlib.Path.cwd(), *pathlib.Path.cwd().parents]:
if (_root / "engcomprheo" / "__init__.py").exists():
sys.path.insert(0, str(_root))
break
else: # on Google Colab: install from GitHub
subprocess.run([sys.executable, "-m", "pip", "install", "-q",
"git+https://github.com/ktwyw/engcomprheo.git"], check=True)
import engcomprheo
import inspect
import math
import numpy as np
import matplotlib.pyplot as plt
from engcomprheo import (brownian_chains, constants_benchmarks, entangled_tubes, mesoscopic_suspensions_dpd,
microrheology_rheoml, shear_banding_instabilities, tensors_kinematics,
viscoelastic_fvm_2d, viscoplastic_admm)
from engcomprheo.plotting import label_panels, log_ticks, panel_label, use_style
use_style()
trapezoid = getattr(np, "trapezoid", None) or np.trapz # NumPy 2 renamed trapz to trapezoid
def show_source(obj):
"""Return the source code of a function or class of the package."""
return inspect.getsource(obj)
def heading(text):
print(f"\n{text}\n" + "=" * len(text))1. Relaxation times of Rouse and Zimm chains¶
A linear polymer is modelled as beads at the positions , joined by Hookean springs, in units in which , and . In the model of Rouse (1953) each bead has its own friction and the beads do not interact through the solvent (). The motion of the chain then separates into the modes of the connectivity matrix , whose non-zero eigenvalues () are known in closed form:
In a dilute solution the motion of one bead moves the solvent at the positions of the others. Zimm (1956) introduced the hydrodynamic interaction parameter , which is at most about 0.25, and replaced the hydrodynamic interaction tensor by its average at equilibrium. For a Gaussian chain , which gives the matrix
where are the non-zero eigenvalues of . The function simulate_rouse_zimm_chain_bd returns these relaxation times. For long chains the longest one grows as , against for the Rouse chain. For short chains the difference is small, and the fast modes of the Zimm chain are slower than those of the Rouse chain at the same bead friction.
heading("Demonstration 1: relaxation times of Rouse and Zimm chains")
N8 = 8
A_rouse = np.zeros((N8, N8), dtype=float)
for i in range(N8):
if i > 0:
A_rouse[i, i] += 1.0; A_rouse[i, i - 1] -= 1.0
if i < N8 - 1:
A_rouse[i, i] += 1.0; A_rouse[i, i + 1] -= 1.0
evals_A = np.sort(np.linalg.eigvalsh(A_rouse))[1:] # Drop p=0 center-of-mass translation mode
tau_from_laplacian = 1.0 / (2.0 * evals_A)
rz8_r = brownian_chains.simulate_rouse_zimm_chain_bd(n_beads=8, h_star=0.0, n_steps=1, n_chains=1, use_hi=False)
rz8_z = brownian_chains.simulate_rouse_zimm_chain_bd(n_beads=8, h_star=0.25, n_steps=1, n_chains=1, use_hi=True)
assert np.allclose(tau_from_laplacian, rz8_r["relaxation_modes"], atol=1e-13)
n_beads_sweep = np.array([6, 10, 16, 24, 36])
tau1_rouse_n, tau1_zimm_n = [], []
for nb in n_beads_sweep:
rr = brownian_chains.simulate_rouse_zimm_chain_bd(n_beads=int(nb), h_star=0.0, n_steps=1, n_chains=1, use_hi=False)
rz = brownian_chains.simulate_rouse_zimm_chain_bd(n_beads=int(nb), h_star=0.25, n_steps=1, n_chains=1, use_hi=True)
tau1_rouse_n.append(float(rr["relaxation_modes"][0]))
tau1_zimm_n.append(float(rz["relaxation_modes"][0]))
exp_rouse = float(np.polyfit(np.log(n_beads_sweep[-3:]), np.log(tau1_rouse_n[-3:]), 1)[0])
exp_zimm = float(np.polyfit(np.log(n_beads_sweep[-3:]), np.log(tau1_zimm_n[-3:]), 1)[0])
print(f"8-bead Laplacian against package Rouse modes max diff: {np.max(np.abs(tau_from_laplacian - rz8_r['relaxation_modes'])):.3e}")
print(f"Exponent of tau_1 ~ N^nu fitted over N = 16, 24, 36 -> Rouse: {exp_rouse:.3f} (limit 2), Zimm: {exp_zimm:.3f} (limit 3/2)")
assert 1.98 < exp_rouse < 2.02
assert 1.45 < exp_zimm < 1.56
fig, axes = plt.subplots(1, 2, figsize=(10.5, 3.8))
p_idx = np.arange(1, N8)
axes[0].semilogy(p_idx, rz8_r["relaxation_modes"], "-o", color="#2166AC", lw=2.0, ms=5.5, label="Rouse ($h^*=0$)")
axes[0].semilogy(p_idx, rz8_z["relaxation_modes"], "-s", color="#2E8B57", lw=2.0, ms=5.5, label="Zimm ($h^*=0.25$)")
axes[0].set_xlabel("Normal mode index $p$")
axes[0].set_ylabel(r"Mode relaxation time $\tau_p$")
axes[0].set_title(r"Relaxation times of an 8-bead chain")
axes[0].legend(fontsize=8.5)
axes[1].loglog(n_beads_sweep, tau1_rouse_n, "-o", color="#2166AC", lw=2.1, ms=5.5, label=rf"Rouse $\tau_1 \propto N^{{{exp_rouse:.2f}}}$")
axes[1].loglog(n_beads_sweep, tau1_zimm_n, "-s", color="#2E8B57", lw=2.1, ms=5.5, label=rf"Zimm $\tau_1 \propto N^{{{exp_zimm:.2f}}}$")
axes[1].set_xlabel("Chain length $N$ [beads]")
axes[1].set_ylabel(r"Longest relaxation time $\tau_1(N)$")
axes[1].set_title(r"Longest relaxation time against chain length")
axes[1].legend(fontsize=8.5)
log_ticks(axes[1], "x", [6, 10, 16, 24, 36])
label_panels(fig)
plt.show()
Demonstration 1: relaxation times of Rouse and Zimm chains
==========================================================
8-bead Laplacian against package Rouse modes max diff: 1.332e-15
Exponent of tau_1 ~ N^nu fitted over N = 16, 24, 36 -> Rouse: 1.997 (limit 2), Zimm: 1.503 (limit 3/2)

Figure 5.1. (a) Relaxation times of the modes of an 8-bead chain: Rouse, and Zimm with pre-averaged hydrodynamic interaction (). (b) Longest relaxation time against the number of beads; the exponents fitted over to 36 are 2.00 and 1.50.
2. The Rotne–Prager–Yamakawa mobility and the Oseen mobility¶
In a simulation with hydrodynamic interaction (Ermak and McCammon, 1978) the random displacements of the beads are correlated: they are , where the matrix satisfies and is the mobility matrix. A real matrix exists only if is positive semi-definite.
The Oseen tensor, , treats beads of radius as points. When two beads are closer than , the coupling between them exceeds the mobility of a single bead, and the mobility matrix has a negative eigenvalue. Rotne and Prager (1969) and Yamakawa (1970) derived the mobility of two spheres of finite radius :
This mobility is positive definite at all distances, and it is continuous with a continuous first derivative at .
heading("Demonstration 2: the Rotne-Prager-Yamakawa and Oseen mobilities of two beads")
r_over_a = np.linspace(0.08, 4.0, 120)
min_eig_rpy, min_eig_oseen, d_xx_rpy, d_xx_oseen = [], [], [], []
zeta0_inv = 1.0 / (6.0 * math.pi) # a = 1.0, eta_s = 1.0
for rv in r_over_a:
pos2 = np.array([[0.0, 0.0, 0.0], [float(rv), 0.0, 0.0]])
Dr = brownian_chains.rpy_mobility_tensor(pos2, bead_radius_a=1.0, eta_s=1.0, oseen_unsafe=False)
Do = brownian_chains.rpy_mobility_tensor(pos2, bead_radius_a=1.0, eta_s=1.0, oseen_unsafe=True)
min_eig_rpy.append(float(np.min(np.linalg.eigvalsh(Dr))) / zeta0_inv)
min_eig_oseen.append(float(np.min(np.linalg.eigvalsh(Do))) / zeta0_inv)
d_xx_rpy.append(float(Dr[0, 3]) / zeta0_inv)
d_xx_oseen.append(float(Do[0, 3]) / zeta0_inv)
D_minus = brownian_chains.rpy_mobility_tensor(np.array([[0.0, 0.0, 0.0], [1.999999, 0.0, 0.0]]), bead_radius_a=1.0)
D_plus = brownian_chains.rpy_mobility_tensor(np.array([[0.0, 0.0, 0.0], [2.000001, 0.0, 0.0]]), bead_radius_a=1.0)
jump_2a = float(np.max(np.abs(D_plus - D_minus))) / zeta0_inv
print(f"Continuity jump across r = 2a: {jump_2a:.3e}")
print(f"Minimum normalized eigenvalue across r/a in [0.08, 4.0] -> RPY: {min(min_eig_rpy):.4f} (> 0), Oseen: {min(min_eig_oseen):.2f} (< 0)")
assert jump_2a < 1e-5
assert min(min_eig_rpy) > 0.0
assert min(min_eig_oseen) < -5.0
fig, axes = plt.subplots(1, 2, figsize=(10.5, 3.8))
axes[0].plot(r_over_a, d_xx_rpy, color="#2E8B57", lw=2.2, label="RPY longitudinal $D_{12,xx} / D_0$")
axes[0].plot(r_over_a, np.clip(d_xx_oseen, 0.0, 3.0), "--", color="#C0392B", lw=2.0, label="Oseen tensor, $3a/(2r)$ (above 1 for $r < 1.5a$)")
axes[0].axvline(2.0, color="gray", ls=":", label="Contact, $r = 2a$")
axes[0].axhline(1.0, color="k", lw=1.0, ls="--", label="Single-bead mobility $D_0$")
axes[0].set_xlabel("Normalized separation $r / a$")
axes[0].set_ylabel(r"Normalized pair mobility $D_{12,xx} / D_0$")
axes[0].set_title(r"Pair mobility along the line of centres")
axes[0].legend(fontsize=8)
axes[1].plot(r_over_a, min_eig_rpy, color="#2E8B57", lw=2.2, label=r"RPY $\lambda_{\min} / D_0 > 0$ (positive definite)")
axes[1].plot(r_over_a, np.clip(min_eig_oseen, -2.5, 1.0), "--", color="#C0392B", lw=2.0, label=r"Oseen $\lambda_{\min} = 1 - 3a/(2r) < 0$")
axes[1].axhline(0.0, color="k", lw=1.0)
axes[1].axvline(1.5, color="#C0392B", ls=":", label="Oseen limit $r = 1.5a$")
axes[1].set_xlabel("Normalized separation $r / a$")
axes[1].set_ylabel(r"Minimum mobility eigenvalue $\lambda_{\min} / D_0$")
axes[1].set_title(r"Smallest eigenvalue of the two-bead mobility")
axes[1].legend(fontsize=8)
label_panels(fig)
plt.show()
Demonstration 2: the Rotne-Prager-Yamakawa and Oseen mobilities of two beads
============================================================================
Continuity jump across r = 2a: 5.625e-07
Minimum normalized eigenvalue across r/a in [0.08, 4.0] -> RPY: 0.0150 (> 0), Oseen: -17.75 (< 0)

Figure 5.2. Two beads at separation . (a) Longitudinal pair mobility: the Oseen form exceeds the self-mobility for (clipped at 3 in the plot), the Rotne–Prager–Yamakawa form is continuous at and bounded. (b) Smallest eigenvalue of the mobility matrix: negative for the Oseen form below , positive for Rotne–Prager–Yamakawa.
3. Brownian dynamics of chains in shear, without and with hydrodynamic interaction¶
The demonstration simulates 60 chains of six beads in shear at the rates 0, 0.5, 1.0 and 1.5, without hydrodynamic interaction (use_hi=False) and with the Rotne–Prager–Yamakawa mobility (use_hi=True, h_star=0.25). At equilibrium the mean-square radius of gyration and end-to-end distance are the same in both cases: hydrodynamic interaction changes the dynamics and leaves the equilibrium distribution, which depends on the spring potential alone, unchanged. In shear the chains with hydrodynamic interaction stretch less and carry a lower shear stress. The runs last 8 time units (about four times the longest Rouse relaxation time of a 6-bead chain, 1.87) and the averages are taken over the second half.
heading("Demonstration 3: 6-bead Rouse chains and chains with hydrodynamic interaction in shear")
rates_rz = np.array([0.0, 0.5, 1.0, 1.5])
rg2_r, rg2_z, stress_r, stress_z = [], [], [], []
for sr in rates_rz:
sim_r = brownian_chains.simulate_rouse_zimm_chain_bd(
n_beads=6, h_star=0.0, shear_rate=float(sr), n_steps=400, dt=0.02, n_chains=60, use_hi=False, seed=14
)
sim_z = brownian_chains.simulate_rouse_zimm_chain_bd(
n_beads=6, h_star=0.25, shear_rate=float(sr), n_steps=400, dt=0.02, n_chains=60, use_hi=True, seed=14
)
assert sim_z["spd_preserved"] and sim_z["min_mobility_eig"] > 0.0
rg2_r.append(sim_r["rg2_mean"])
rg2_z.append(sim_z["rg2_mean"])
stress_r.append(sim_r["intrinsic_stress_xy"])
stress_z.append(sim_z["intrinsic_stress_xy"])
rg2_eq_exact = (6**2 - 1.0) / (2.0 * 6.0)
eta0_rouse = float(np.sum(sim_r["relaxation_modes"])) # Rouse: tau_xy = shear rate * sum of relaxation times
print(f"Equilibrium <Rg^2> (rate=0): Rouse={rg2_r[0]:.3f}, Zimm={rg2_z[0]:.3f} (analytical Gaussian = {rg2_eq_exact:.4f})")
print(f"Shear rate = 0.5 stress_xy -> Rouse BD: {stress_r[1]:.2f} (exact steady value {0.5 * eta0_rouse:.2f}), RPY BD: {stress_z[1]:.2f}")
print(f"Shear rate = 1.5 stress_xy -> Rouse BD: {stress_r[-1]:.2f} (exact steady value {1.5 * eta0_rouse:.2f}), RPY BD: {stress_z[-1]:.2f}")
print(f"Shear rate = 1.5 <Rg^2> -> Rouse BD: {rg2_r[-1]:.2f}, RPY BD: {rg2_z[-1]:.2f}")
assert 2.0 < rg2_r[0] < 4.0 and 2.0 < rg2_z[0] < 4.0
assert stress_z[-1] < stress_r[-1] and rg2_z[-1] < rg2_r[-1]
fig, axes = plt.subplots(1, 2, figsize=(10.5, 3.8))
axes[0].plot(rates_rz, stress_r, "-o", color="#2166AC", lw=2.1, ms=5.5, label="Rouse ($h^*=0$)")
axes[0].plot(rates_rz, stress_z, "-s", color="#2E8B57", lw=2.1, ms=5.5, label="With hydrodynamic interaction ($h^*=0.25$)")
axes[0].set_xlabel(r"Dimensionless shear rate $\dot{\gamma}$")
axes[0].set_ylabel(r"Shear stress $\tau_{xy}$")
axes[0].plot(rates_rz, rates_rz * eta0_rouse, "k:", lw=1.3, label="Rouse, exact steady value")
axes[0].set_title(r"Shear stress")
axes[0].legend(fontsize=8.5)
axes[1].plot(rates_rz, rg2_r, "-o", color="#2166AC", lw=2.1, ms=5.5, label=r"Rouse $\langle R_g^2 \rangle$")
axes[1].plot(rates_rz, rg2_z, "-s", color="#2E8B57", lw=2.1, ms=5.5, label=r"With hydrodynamic interaction, $\langle R_g^2 \rangle$")
axes[1].axhline(rg2_eq_exact, color="gray", ls=":", label=rf"Equilibrium $(N^2-1)/(2N) = {rg2_eq_exact:.2f}$")
axes[1].set_xlabel(r"Dimensionless shear rate $\dot{\gamma}$")
axes[1].set_ylabel(r"Mean-square gyration radius $\langle R_g^2 \rangle$")
axes[1].set_title(r"Mean-square radius of gyration")
axes[1].legend(fontsize=8.5)
label_panels(fig)
plt.show()
Demonstration 3: 6-bead Rouse chains and chains with hydrodynamic interaction in shear
======================================================================================
Equilibrium <Rg^2> (rate=0): Rouse=3.037, Zimm=2.865 (analytical Gaussian = 2.9167)
Shear rate = 0.5 stress_xy -> Rouse BD: 1.47 (exact steady value 1.46), RPY BD: 1.39
Shear rate = 1.5 stress_xy -> Rouse BD: 4.08 (exact steady value 4.38), RPY BD: 3.61
Shear rate = 1.5 <Rg^2> -> Rouse BD: 12.10, RPY BD: 8.65

Figure 5.3. Brownian dynamics of 60 six-bead chains, averaged over the second half of runs of 8 time units. (a) Shear stress without and with hydrodynamic interaction; the dotted line is the exact steady value for the Rouse chain. (b) Mean-square radius of gyration; the dotted line is the equilibrium value 2.92.
4. Dynamic moduli: the slopes 1/2 and 2/3¶
Each mode contributes a Maxwell element to the moduli, and . At frequencies between the inverse of the longest and of the shortest relaxation time () the sums give power laws in the limit of long chains:
Rouse (
h* = 0): gives , with a phase angle of .Zimm (
h* > 0): gives and , with a phase angle of .
A chain of 100 beads is still some way from this limit: the fitted slopes of and lie on either side of the limiting value, so the demonstration fits the slope of .
heading("Demonstration 4: dynamic moduli of 100-bead Rouse and Zimm chains")
N_long = 100
modes_r = brownian_chains.simulate_rouse_zimm_chain_bd(n_beads=N_long, h_star=0.0, n_steps=1, n_chains=1, use_hi=False)["relaxation_modes"]
modes_z = brownian_chains.simulate_rouse_zimm_chain_bd(n_beads=N_long, h_star=0.25, n_steps=1, n_chains=1, use_hi=True)["relaxation_modes"]
# Exponent of tau_p ~ p^(-nu) over the slowest quarter of the modes
p_fit = np.arange(1, N_long // 4)
nu_rouse = -float(np.polyfit(np.log(p_fit), np.log(modes_r[: p_fit.size]), 1)[0])
nu_zimm = -float(np.polyfit(np.log(p_fit), np.log(modes_z[: p_fit.size]), 1)[0])
def moduli(om, tau):
wt = om[:, None] * tau[None, :]
return np.sum(wt**2 / (1.0 + wt**2), axis=1), np.sum(wt / (1.0 + wt**2), axis=1)
om_grid = np.logspace(-4.0, 1.5, 160)
gp_r, gpp_r = moduli(om_grid, modes_r)
gp_z, gpp_z = moduli(om_grid, modes_z)
# Slope of |G*| between the slowest and the fastest relaxation rate
mid_r = (om_grid > 3.0 / modes_r[0]) & (om_grid < 0.3 / modes_r[-1])
mid_z = (om_grid > 3.0 / modes_z[0]) & (om_grid < 0.3 / modes_z[-1])
slope_rouse = float(np.polyfit(np.log(om_grid[mid_r]), np.log(np.hypot(gp_r, gpp_r)[mid_r]), 1)[0])
slope_zimm = float(np.polyfit(np.log(om_grid[mid_z]), np.log(np.hypot(gp_z, gpp_z)[mid_z]), 1)[0])
print(f"Exponent of tau_p ~ p^(-nu), modes 1 to {p_fit[-1]} -> Rouse: {nu_rouse:.3f} (limit 2), Zimm: {nu_zimm:.3f} (limit 3/2)")
print(f"Slope of |G*|(omega) in the intermediate range -> Rouse: {slope_rouse:.3f} (limit 1/2), Zimm: {slope_zimm:.3f} (limit 2/3)")
assert 1.95 < nu_rouse < 2.02 and 1.48 < nu_zimm < 1.58
assert 0.47 < slope_rouse < 0.56 and 0.60 < slope_zimm < 0.72
fig, axes = plt.subplots(1, 2, figsize=(10.5, 3.8))
axes[0].loglog(om_grid, gp_r, "-", color="#2166AC", lw=2.1, label=r"$G'(\omega)$")
axes[0].loglog(om_grid, gpp_r, "--", color="#2166AC", lw=1.9, label=r"$G''(\omega)$")
axes[0].loglog(om_grid[mid_r], 4.0 * np.hypot(gp_r, gpp_r)[mid_r][0] * (om_grid[mid_r] / om_grid[mid_r][0]) ** 0.5, "k:", lw=1.8, label=r"Slope $1/2$")
axes[0].set_xlabel(r"Dimensionless frequency $\omega$")
axes[0].set_ylabel(r"Moduli $G', G'' / (n_c k_B T)$")
axes[0].set_title(r"100-bead Rouse chain")
axes[0].legend(fontsize=8, loc="lower right")
axes[1].loglog(om_grid, gp_z, "-", color="#2E8B57", lw=2.1, label=r"$G'(\omega)$")
axes[1].loglog(om_grid, gpp_z, "--", color="#2E8B57", lw=1.9, label=r"$G''(\omega)$")
axes[1].loglog(om_grid[mid_z], 4.0 * np.hypot(gp_z, gpp_z)[mid_z][0] * (om_grid[mid_z] / om_grid[mid_z][0]) ** (2.0 / 3.0), "k:", lw=1.8, label=r"Slope $2/3$")
axes[1].set_xlabel(r"Dimensionless frequency $\omega$")
axes[1].set_ylabel(r"Moduli $G', G'' / (n_c k_B T)$")
axes[1].set_title(r"100-bead Zimm chain")
axes[1].legend(fontsize=8, loc="lower right")
label_panels(fig)
plt.show()
Demonstration 4: dynamic moduli of 100-bead Rouse and Zimm chains
=================================================================
Exponent of tau_p ~ p^(-nu), modes 1 to 24 -> Rouse: 1.985 (limit 2), Zimm: 1.524 (limit 3/2)
Slope of |G*|(omega) in the intermediate range -> Rouse: 0.516 (limit 1/2), Zimm: 0.627 (limit 2/3)

Figure 5.4. Storage and loss moduli from the relaxation times of 100-bead chains. (a) Rouse. (b) Zimm with . The dotted segments have the limiting slopes 1/2 and 2/3; the fitted slopes of are 0.52 and 0.63.
Inside the algorithm¶
The cell below prints the source of brownian_chains.rpy_mobility_tensor. When the mobility depends on the configuration, the stochastic differential equation in the Itô form needs the additional drift for the simulation to sample the Boltzmann distribution. The function simulate_rouse_zimm_chain_bd contains no such term, for the reason given below.
Check against the package¶
The velocity field of Stokes flow is divergence free, and as a consequence , both for and for overlapping beads, . The check below verifies this by central differences for a cluster of four beads that contains overlapping and non-overlapping pairs: the divergence of the mobility is zero to 10-10.
heading("Inside the algorithm: the mobility matrix and its divergence")
print(show_source(brownian_chains.rpy_mobility_tensor))
# 4-bead cluster containing both overlapping (r = 0.85a < 2a) and separated (r > 2a) bead pairs:
pos_cluster = np.array([
[0.0, 0.0, 0.0],
[0.75, 0.40, 0.0], # r_01 = 0.85 < 2a (Yamakawa overlap branch)
[-0.30, 1.10, 0.20], # r_02 = 1.16 < 2a (overlap)
[2.60, -0.50, 0.90], # r > 2a (Rotne-Prager far-field branch)
], dtype=float)
a_test = 1.0
D_cluster = brownian_chains.rpy_mobility_tensor(pos_cluster, bead_radius_a=a_test, eta_s=1.0)
evals_cluster = np.linalg.eigvalsh(D_cluster)
# Compute 3N-vector thermal drift div_R(D)_ia = sum_{j, beta} d(D_{ia, jb}) / d(R_{j, beta}) via central FD:
eps_r = 1e-6
div_D = np.zeros(3 * pos_cluster.shape[0], dtype=float)
for j in range(pos_cluster.shape[0]):
for beta in range(3):
p_plus = pos_cluster.copy(); p_plus[j, beta] += eps_r
p_minus = pos_cluster.copy(); p_minus[j, beta] -= eps_r
dD = (
brownian_chains.rpy_mobility_tensor(p_plus, bead_radius_a=a_test)
- brownian_chains.rpy_mobility_tensor(p_minus, bead_radius_a=a_test)
) / (2.0 * eps_r)
div_D += dD[:, 3 * j + beta]
max_div = float(np.max(np.abs(div_D)))
print(f"4-bead mixed-overlap RPY min eigenvalue: {np.min(evals_cluster):.5e} > 0 (positive definite)")
print(f"Max thermal drift |div_R(D_RPY)| : {max_div:.3e} == 0")
assert float(np.min(evals_cluster)) > 0.0
assert max_div < 1e-10
Inside the algorithm: the mobility matrix and its divergence
============================================================
def rpy_mobility_tensor(
positions: np.ndarray, bead_radius_a: float, eta_s: float = 1.0, oseen_unsafe: bool = False
) -> np.ndarray:
"""Assemble the 3N x 3N Rotne-Prager-Yamakawa mobility, which is positive definite at all distances."""
pos = np.asarray(positions, dtype=float)
if pos.ndim != 2 or pos.shape[1] != 3 or bead_radius_a <= 0.0 or eta_s <= 0.0:
raise ValueError("Require (N, 3) positions, bead_radius_a > 0, and eta_s > 0.")
n_b = pos.shape[0]
a = float(bead_radius_a)
zeta_inv = 1.0 / (6.0 * math.pi * float(eta_s) * a)
D_mob = np.zeros((3 * n_b, 3 * n_b), dtype=float)
I3 = np.eye(3, dtype=float)
for i in range(n_b):
D_mob[3 * i : 3 * i + 3, 3 * i : 3 * i + 3] = zeta_inv * I3
for j in range(i + 1, n_b):
rij = pos[i] - pos[j]
r = float(np.linalg.norm(rij))
if r < 1e-14:
block = zeta_inv * I3
else:
uhat = rij / r
uu = np.outer(uhat, uhat)
if oseen_unsafe:
block = (1.0 / (8.0 * math.pi * float(eta_s) * r)) * (I3 + uu)
elif r >= 2.0 * a:
c1 = (3.0 * a) / (4.0 * r)
a2_r2 = (a * a) / (r * r)
block = zeta_inv * c1 * ((1.0 + (2.0 / 3.0) * a2_r2) * I3 + (1.0 - 2.0 * a2_r2) * uu)
else:
# Yamakawa (1970) exact overlap branch guaranteeing positive-definiteness for r < 2a:
s = r / (2.0 * a)
block = zeta_inv * ((1.0 - (9.0 / 16.0) * s) * I3 + (3.0 / 16.0) * s * uu)
D_mob[3 * i : 3 * i + 3, 3 * j : 3 * j + 3] = block
D_mob[3 * j : 3 * j + 3, 3 * i : 3 * i + 3] = block
return 0.5 * (D_mob + D_mob.T)
4-bead mixed-overlap RPY min eigenvalue: 7.42506e-03 > 0 (positive definite)
Max thermal drift |div_R(D_RPY)| : 6.830e-12 == 0
Exercises¶
Worked solutions are in 05_solutions.ipynb. The cell below the list is a short self-check to start from.
Verify a result. Check by sampling Gaussian chains (35 000 chains for each ) with beads that , and , which tends to 6 for long chains.
Find how it fails. Compare the Oseen mobility (
oseen_unsafe=True) with the Rotne–Prager–Yamakawa mobility (oseen_unsafe=False) for three beads of radius at the corners of an equilateral triangle of side , , for between 0.20 and 2.50. Count the failures of the Cholesky factorization and plot the smallest eigenvalue against .Implement it yourself. Write a Brownian dynamics integrator in NumPy for chains with Rotne–Prager–Yamakawa hydrodynamic interaction that generates the correlated random displacements with a Cholesky factor of the diffusion matrix (
np.linalg.cholesky). Use 6-bead chains with , and , and compare and the shear stress withbrownian_chains.simulate_rouse_zimm_chain_bd.
heading("Self-check for the exercises")
atlas_05 = [entry for entry in constants_benchmarks.RHEO_ATLAS_DB if entry["lecture"] == "05"]
assert len(atlas_05) == 2
assert min(min_eig_rpy) > 0.0 and min(min_eig_oseen) < -5.0
assert max_div < 1e-10
print("All checks passed.")
Self-check for the exercises
============================
All checks passed.