Below its yield stress a polymer gel such as a Carbopol dispersion is not rigid, as the Bingham model assumes: it deforms elastically and recovers when the load is removed. Above the yield stress it flows, and when the driving stress is removed the elastic strain is recovered, so that the material moves backwards for a short time. The Bingham model has no elasticity, and the Oldroyd-B model has no yield stress.
The model of Saramito (2007) combines the two: an elastic solid below the yield stress and a viscoelastic fluid above it, with a von Mises yield criterion. This lecture integrates the model in creep, in start-up of shear, in oscillatory shear and in recovery. The parameter set CARBOPOL_EVP used throughout (, ) is assumed and is not fitted to measurements.
Learning objectives¶
Write the Saramito model and show the change from an elastic solid () to a viscoelastic fluid above the yield stress (
viscoplastic_admm.solve_saramito_evp_1d).Compute start-up of shear at a fixed rate: the elastic rise of the stress, yielding and the overshoot.
Compute the stress–strain loops of large-amplitude oscillatory shear below and above the yield strain .
Compute the recoil after the stress is removed, for several values of the modulus .
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. The Saramito model¶
Saramito (2007) multiplied the relaxation term of the Oldroyd-B model by a factor that is zero below the yield stress. The yield criterion is of the von Mises type, on the norm of the deviatoric stress. In shear, with the total shear stress and the relaxation time :
The function switches between a solid and a fluid, without the creep of a regularized model:
Below the yield stress, , and there is no relaxation. In shear , so that : under a constant stress the strain tends to and the shear rate to zero.
Above the yield stress, , and the material relaxes as a viscoelastic fluid, with positive dissipation.
heading("Demonstration 1: creep below and above the yield stress (CARBOPOL_EVP)")
carb = constants_benchmarks.BENCHMARK_FLUIDS_DB["CARBOPOL_EVP"]
G0_c, ty_c, etas_c = carb["G0_Pa"], carb["tau_y_Pa"], carb["eta_s_Pas"]
etap_c = 12.0
# Choose dt = 0.0005 s so explicit Kelvin-Voigt stiffness G0 * dt / eta_s = 0.38 < 1
t_evp1 = np.linspace(0.0, 0.60, 1201)
evp_sub = viscoplastic_admm.solve_saramito_evp_1d(
t_evp1, lambda _t: 30.0, G0=G0_c, tau_y=ty_c, eta_p=etap_c, eta_s=etas_c, mode="stress_controlled"
)
evp_sup = viscoplastic_admm.solve_saramito_evp_1d(
t_evp1, lambda _t: 75.0, G0=G0_c, tau_y=ty_c, eta_p=etap_c, eta_s=etas_c, mode="stress_controlled"
)
gamma_hooke_exact = 30.0 / G0_c
print(f"Sub-yield load (30 Pa < tau_y=45 Pa) : final strain = {evp_sub['strain'][-1]:.6f} (exact sigma/G0 = {gamma_hooke_exact:.6f}), final rate = {evp_sub['shear_rate'][-1]:.2e} s^-1, ever yielded? {bool(np.any(evp_sub['yielded_mask']))}")
print(f"Super-yield load (75 Pa > tau_y=45 Pa): final strain = {evp_sup['strain'][-1]:.4f}, steady flow rate = {evp_sup['shear_rate'][-1]:.3f} s^-1, yielded? {bool(evp_sup['yielded_mask'][-1])}")
assert np.isclose(evp_sub["strain"][-1], gamma_hooke_exact, rtol=1e-5)
assert abs(evp_sub["shear_rate"][-1]) < 1e-10
assert not bool(np.any(evp_sub["yielded_mask"]))
assert bool(evp_sup["yielded_mask"][-1]) and evp_sup["shear_rate"][-1] > 1.5
fig, axes = plt.subplots(1, 2, figsize=(10.2, 4.0))
axes[0].plot(t_evp1, evp_sub["strain"], color="#2166AC", lw=2.2, label=r"Sub-yield $\sigma_0 = 30$ Pa ($<\tau_y$)")
axes[0].axhline(gamma_hooke_exact, color="#2166AC", ls=":", lw=1.4, label=r"Hookean plateau $\sigma_0 / G_0$")
axes[0].plot(t_evp1, evp_sup["strain"], color="#C0392B", lw=2.2, label=r"Super-yield $\sigma_0 = 75$ Pa ($>\tau_y$)")
axes[0].set_xlabel("Time $t$ [s]")
axes[0].set_ylabel(r"Shear strain $\gamma(t)$")
axes[0].set_title(r"Strain under constant stress")
axes[0].legend(fontsize=8)
axes[1].plot(t_evp1, evp_sub["shear_rate"], color="#2166AC", lw=2.0, label=r"$\sigma_0 = 30$ Pa ($\dot{\gamma} \to 0$)")
axes[1].plot(t_evp1, evp_sup["shear_rate"], color="#C0392B", lw=2.0, label=r"$\sigma_0 = 75$ Pa (steady viscoplastic)")
axes[1].set_ylim(-2.0, 22.0)
axes[1].set_xlabel("Time $t$ [s]")
axes[1].set_ylabel(r"Shear rate $\dot{\gamma}(t)$ [s$^{-1}$]")
axes[1].set_title(r"Shear rate")
axes[1].legend(fontsize=8)
label_panels(fig)
plt.show()
Demonstration 1: creep below and above the yield stress (CARBOPOL_EVP)
======================================================================
Sub-yield load (30 Pa < tau_y=45 Pa) : final strain = 0.078947 (exact sigma/G0 = 0.078947), final rate = 7.11e-15 s^-1, ever yielded? False
Super-yield load (75 Pa > tau_y=45 Pa): final strain = 1.6965, steady flow rate = 2.528 s^-1, yielded? True

Figure 11.1. Saramito model with the parameters of CARBOPOL_EVP (assumed) under a constant stress. (a) At 30 Pa, below the yield stress, the strain stops at ; at 75 Pa it grows steadily. (b) Shear rate in the two cases.
What Demonstration 1 shows. Below , the strain computed by solve_saramito_evp_1d rises to , correct to six digits, and then stays constant (). At the model yields and flows steadily.
2. Start-up of shear at a fixed rate¶
At an imposed shear rate (mode="rate_controlled") the stress first grows elastically, and , until the norm reaches , near the yield strain . Beyond the yield strain the normal stress continues to grow, , which increases and the rate of relaxation. The shear stress therefore passes through a maximum before it settles on its steady value.
heading("Demonstration 2: start-up of shear: elastic rise, yielding and overshoot")
G0_ov, ty_ov, etap_ov = 150.0, 90.0, 6.0 # Soft-gel paste mode (gamma_y = 0.60) highlighting normal-stress yield overshoot
rates_d2 = [0.5, 1.5, 4.0]
cols_d2 = ["#2166AC", "#E08214", "#C0392B"]
gamma_y_ov = ty_ov / G0_ov
gamma_y = ty_c / G0_c
fig, axes = plt.subplots(1, 2, figsize=(10.2, 4.0))
overshoot_ratios, peak_stresses = [], []
for gd_v, col in zip(rates_d2, cols_d2):
t_rc = np.linspace(0.0, 4.0 / gd_v, 500)
res_rc = viscoplastic_admm.solve_saramito_evp_1d(
t_rc, lambda _t, g=gd_v: g, G0=G0_ov, tau_y=ty_ov, eta_p=etap_ov, eta_s=etas_c, mode="rate_controlled"
)
ov_ratio = float(np.max(res_rc["tau_p"]) / res_rc["tau_p"][-1])
overshoot_ratios.append(ov_ratio)
peak_stresses.append(float(np.max(res_rc["stress"])))
y_idx = int(np.argmax(res_rc["yielded_mask"]))
print(f"gdot = {gd_v:4.1f} s^-1 | yield strain = {res_rc['strain'][y_idx]:.4f} (tau_y/G0 = {gamma_y_ov:.4f}) | peak/steady tau_xy = {ov_ratio:.3f}")
axes[0].plot(res_rc["strain"], res_rc["stress"], lw=2.1, color=col, label=f"$\\dot{{\\gamma}}_0 = {gd_v:.1f}\\,\\mathrm{{s}}^{{-1}}$")
axes[1].plot(res_rc["strain"], res_rc["tau_p"], lw=2.1, color=col, label=f"$\\dot{{\\gamma}}_0 = {gd_v:.1f}\\,\\mathrm{{s}}^{{-1}}$ (peak/steady $={ov_ratio:.2f}$)")
g_lin = np.linspace(0.0, 0.70, 50)
axes[0].plot(g_lin, G0_ov * g_lin, "k--", lw=1.5, label=r"Hookean tangent $G_0\gamma$")
axes[0].axhline(ty_ov, color="gray", ls=":", lw=1.3, label=f"Yield stress $\\tau_y = {ty_ov:.0f}$ Pa")
axes[0].set_xlim(0.0, 4.0)
axes[0].set_xlabel(r"Shear strain $\gamma = \dot{\gamma}_0 t$")
axes[0].set_ylabel(r"Total shear stress $\sigma$ [Pa]")
axes[0].set_title(r"Total stress against strain")
axes[0].legend(fontsize=8)
axes[1].axvline(gamma_y_ov, color="gray", ls=":", lw=1.3, label=r"Yield strain $\gamma_y = \tau_y/G_0$")
axes[1].set_xlim(0.0, 4.0)
axes[1].set_xlabel(r"Shear strain $\gamma = \dot{\gamma}_0 t$")
axes[1].set_ylabel(r"Elastoviscoplastic stress $\tau_{xy}$ [Pa]")
axes[1].set_title(r"Polymer shear stress against strain")
axes[1].legend(fontsize=8)
label_panels(fig)
plt.show()
assert min(overshoot_ratios) > 1.08
assert peak_stresses[0] < peak_stresses[1] < peak_stresses[2]
Demonstration 2: start-up of shear: elastic rise, yielding and overshoot
========================================================================
gdot = 0.5 s^-1 | yield strain = 0.5611 (tau_y/G0 = 0.6000) | peak/steady tau_xy = 1.128
gdot = 1.5 s^-1 | yield strain = 0.5611 (tau_y/G0 = 0.6000) | peak/steady tau_xy = 1.117
gdot = 4.0 s^-1 | yield strain = 0.5611 (tau_y/G0 = 0.6000) | peak/steady tau_xy = 1.095

Figure 11.2. Start-up at three shear rates. (a) Total shear stress against strain, with the elastic line . (b) Polymer shear stress; the peak exceeds the steady value by 9.5 to 12.8 %.
What Demonstration 2 shows. At all three shear rates (0.5 to ), the shear stress passes through a maximum above its steady value. The maximum comes from the normal stress , which enters the von Mises norm.
3. Large-amplitude oscillatory shear¶
In oscillatory shear, and , the change from solid to fluid is visible in a plot of the stress against the strain :
For a strain amplitude below the yield strain, , the material does not yield (). The curve is close to a straight line of slope , and the area of the loop is the dissipation of the solvent, .
For the material yields in each half-cycle, and the loop opens into a parallelogram. Its area is the energy dissipated in one cycle per unit volume, by plastic flow and by the solvent.
heading("Demonstration 3: stress-strain loops below and above the yield strain")
omega_laos = 4.0 # [rad/s]
period = 2.0 * math.pi / omega_laos
t_laos = np.linspace(0.0, 3.0 * period, 1500)
amplitudes = [0.05, 0.20, 0.70]
cols_l = ["#2166AC", "#E08214", "#C0392B"]
fig, axes = plt.subplots(1, 2, figsize=(10.2, 4.0))
norm_dissip = []
for gam0, col in zip(amplitudes, cols_l):
sol_l = viscoplastic_admm.solve_saramito_evp_1d(
t_laos,
lambda t, g0=gam0: g0 * omega_laos * math.cos(omega_laos * t),
G0=G0_c, tau_y=ty_c, eta_p=etap_c, eta_s=etas_c, mode="rate_controlled",
)
# Extract final steady limit cycle (last 500 points = 1 full period):
cyc_g = gam0 * np.sin(omega_laos * t_laos[-500:])
cyc_s = sol_l["stress"][-500:]
# Enclosed cycle energy W_d = integral(sigma * gdot dt) over 1 period:
cyc_t = t_laos[-500:]
cyc_rate = sol_l["shear_rate"][-500:]
w_diss = float(trapezoid(cyc_s * cyc_rate, cyc_t))
w_solvent_only = math.pi * etas_c * omega_laos * (gam0**2)
plastic_ratio = w_diss / w_solvent_only
norm_dissip.append(plastic_ratio)
print(f"gamma_0 = {gam0:4.2f} (gamma_0/gamma_y = {gam0/gamma_y:4.2f}) | cycle dissipation W_d = {w_diss:7.2f} J/m^3 ({plastic_ratio:5.2f}x solvent baseline)")
axes[0].plot(cyc_g / gam0, cyc_s, lw=2.1, color=col, label=f"$\\gamma_0 = {gam0:.2f}$ ($W_d={w_diss:.1f}$ J/m$^3$)")
assert np.isclose(norm_dissip[0], 1.0, rtol=0.03) # Sub-yield: 0 plastic dissipation
assert norm_dissip[2] > 6.0 * norm_dissip[0] # Deep LAOS: strong plastic loop opening
axes[0].axhline(ty_c, color="gray", ls=":", lw=1.2)
axes[0].axhline(-ty_c, color="gray", ls=":", lw=1.2, label=r"$\pm\tau_y$")
axes[0].set_xlabel(r"Normalized strain $\gamma(t) / \gamma_0$")
axes[0].set_ylabel(r"Total shear stress $\sigma(t)$ [Pa]")
axes[0].set_title(r"Stress against strain in oscillation")
axes[0].legend(fontsize=8, loc="upper center", bbox_to_anchor=(0.5, -0.17), ncol=3)
axes[1].bar([f"$\\gamma_0={g:.2f}$" for g in amplitudes], norm_dissip, color=cols_l)
axes[1].axhline(1.0, color="black", ls="--", lw=1.3, label="Purely elastic solid ($W_{\\mathrm{plastic}} = 0$)")
axes[1].set_ylabel(r"Total / solvent cycle dissipation $W_d / (\pi\eta_s\omega\gamma_0^2)$")
axes[1].set_title(r"Dissipation per cycle")
axes[1].legend(fontsize=8, loc="upper center", bbox_to_anchor=(0.5, -0.17), ncol=1)
label_panels(fig)
plt.show()
Demonstration 3: stress-strain loops below and above the yield strain
=====================================================================
gamma_0 = 0.05 (gamma_0/gamma_y = 0.42) | cycle dissipation W_d = 0.02 J/m^3 ( 1.00x solvent baseline)
gamma_0 = 0.20 (gamma_0/gamma_y = 1.69) | cycle dissipation W_d = 16.81 J/m^3 (66.87x solvent baseline)
gamma_0 = 0.70 (gamma_0/gamma_y = 5.91) | cycle dissipation W_d = 166.62 J/m^3 (54.12x solvent baseline)

Figure 11.3. Oscillatory shear at three strain amplitudes. (a) Stress against strain divided by its amplitude; the dotted lines are . (b) Energy dissipated per cycle divided by that of the solvent alone; the dashed line is 1.
What Demonstration 3 shows. At , the dissipation in one cycle equals that of the solvent alone (), whereas at the dissipation per cycle is about 54 times that of the solvent alone.
4. Creep and recovery¶
Consider a stress that drops from to , as in a dispensing nozzle when the pressure is removed. While it flows, the gel carries an elastic stress . After the stress is removed, the balance gives a negative shear rate, : the material recoils, and recovers a strain of order .
heading("Demonstration 4: recoil after unloading for several moduli")
t_off = 0.35
t_rec = np.linspace(0.0, 0.75, 1876) # dt = 0.0004 s (stable even for G0 = 760 Pa)
idx_off = int(np.searchsorted(t_rec, t_off))
G0_sweep = [190.0, 380.0, 760.0]
cols_g = ["#C0392B", "#2166AC", "#2E8B57"]
fig, axes = plt.subplots(1, 2, figsize=(10.2, 4.0))
recoil_strains = []
for gv, col in zip(G0_sweep, cols_g):
sol_r = viscoplastic_admm.solve_saramito_evp_1d(
t_rec,
lambda t: 80.0 if t < t_off else 0.0,
G0=gv, tau_y=ty_c, eta_p=etap_c, eta_s=etas_c, mode="stress_controlled",
)
min_rate = float(np.min(sol_r["shear_rate"][idx_off:]))
dgamma_rec = float(sol_r["strain"][-1] - sol_r["strain"][idx_off])
recoil_strains.append(abs(dgamma_rec))
print(f"G0 = {gv:5.1f} Pa | min post-shutoff rate = {min_rate:8.2f} s^-1 (< 0) | recovered strain |dgamma_rec| = {abs(dgamma_rec):.4f}")
assert min_rate < -50.0
assert dgamma_rec < -0.04
axes[0].plot(t_rec, sol_r["strain"], lw=2.1, color=col, label=f"$G_0 = {gv:.0f}$ Pa ($\\Delta\\gamma_{{\\mathrm{{rec}}}} = {dgamma_rec:.3f}$)")
axes[1].plot(t_rec, sol_r["shear_rate"], lw=1.9, color=col, label=f"$G_0 = {gv:.0f}$ Pa")
assert recoil_strains[0] > recoil_strains[1] > recoil_strains[2]
axes[0].axvline(t_off, color="black", ls=":", lw=1.3, label="Stress shutoff $\\sigma: 80 \\to 0$ Pa")
axes[0].set_xlabel("Time $t$ [s]")
axes[0].set_ylabel(r"Cumulative strain $\gamma(t)$")
axes[0].set_title(r"Strain")
axes[0].legend(fontsize=8)
axes[1].axhline(0.0, color="black", lw=1.0)
axes[1].axvline(t_off, color="black", ls=":", lw=1.3)
axes[1].set_ylim(-165.0, 35.0)
axes[1].set_xlabel("Time $t$ [s]")
axes[1].set_ylabel(r"Shear rate $\dot{\gamma}(t)$ [s$^{-1}$]")
axes[1].set_title(r"Shear rate")
axes[1].legend(fontsize=8)
label_panels(fig)
plt.show()
Demonstration 4: recoil after unloading for several moduli
==========================================================
G0 = 190.0 Pa | min post-shutoff rate = -156.74 s^-1 (< 0) | recovered strain |dgamma_rec| = 0.4098
G0 = 380.0 Pa | min post-shutoff rate = -157.06 s^-1 (< 0) | recovered strain |dgamma_rec| = 0.2057
G0 = 760.0 Pa | min post-shutoff rate = -157.16 s^-1 (< 0) | recovered strain |dgamma_rec| = 0.1031

Figure 11.4. A stress of 80 Pa removed at s, for three elastic moduli. (a) Strain: part of it is recovered, more for a lower modulus. (b) Shear rate, which is negative just after the stress is removed.
Inside the algorithm¶
Two details of viscoplastic_admm.solve_saramito_evp_1d deserve attention:
The normal stress. Even in simple shear the upper-convected derivative produces a normal stress, , which enters the yield criterion through .
The time step. With an imposed stress (
stress_controlled), substituting gives an equation that relaxes at the rate , as in a Kelvin–Voigt solid. The explicit midpoint scheme is stable only for .
Check against the package¶
The cell below prints the source of solve_saramito_evp_1d and repeats the calculation with a solver written in NumPy that also returns and . The two agree to rounding error (< 1e-13), and after unloading the stress stays within the yield surface, .
heading("Inside the algorithm: a second-order solver of the Saramito model")
print(show_source(viscoplastic_admm.solve_saramito_evp_1d))
def standalone_saramito_rk2(t_grid: np.ndarray, sig_fn, G0: float, tau_y: float, eta_p: float, eta_s: float) -> dict:
"""This solver, NumPy stress-controlled Saramito EVP integrator returning tau_xx, tau_xy, and ||tau_d||."""
lam = eta_p / G0
txx, txy, gam = 0.0, 0.0, 0.0
txy_h = np.zeros_like(t_grid)
vm_h = np.zeros_like(t_grid)
gam_h = np.zeros_like(t_grid)
for k in range(t_grid.size):
tk = float(t_grid[k])
txy_h[k] = txy
vm_h[k] = math.sqrt(0.5 * txx * txx + txy * txy)
gam_h[k] = gam
if k == t_grid.size - 1:
break
dt = float(t_grid[k + 1] - t_grid[k])
def rhs(xx: float, xy: float, te: float) -> tuple[float, float, float]:
gd = (float(sig_fn(te)) - xy) / eta_s
vm = math.sqrt(0.5 * xx * xx + xy * xy)
yf = max(0.0, (vm - tau_y) / max(vm, 1e-15))
return 2.0 * gd * xy - (yf / lam) * xx, G0 * gd - (yf / lam) * xy, gd
k1x, k1y, _ = rhs(txx, txy, tk)
k2x, k2y, g2 = rhs(txx + 0.5 * dt * k1x, txy + 0.5 * dt * k1y, tk + 0.5 * dt)
txx += dt * k2x
txy += dt * k2y
gam += dt * g2
return {"tau_xy": txy_h, "von_mises": vm_h, "strain": gam_h}
t_in = np.linspace(0.0, 0.60, 1201)
fn_in = lambda t: 75.0 if t < 0.30 else 0.0
hand_evp = standalone_saramito_rk2(t_in, fn_in, G0=380.0, tau_y=45.0, eta_p=12.0, eta_s=0.5)
lib_evp = viscoplastic_admm.solve_saramito_evp_1d(t_in, fn_in, G0=380.0, tau_y=45.0, eta_p=12.0, eta_s=0.5, mode="stress_controlled")
err_gam = float(np.max(np.abs(hand_evp["strain"] - lib_evp["strain"])))
err_txy = float(np.max(np.abs(hand_evp["tau_xy"] - lib_evp["tau_p"])))
# After unloading to sigma = 0, shear stress decays to 0 while residual locked normal stress satisfies ||tau_d|| <= tau_y
print(f"Max |this solver - package| strain error = {err_gam:.3e}, stress error = {err_txy:.3e}")
print(f"Final residual von Mises stress after unloading = {hand_evp['von_mises'][-1]:.3f} Pa <= tau_y = 45.0 Pa")
assert err_gam < 1e-14 and err_txy < 1e-13
assert hand_evp["von_mises"][-1] <= 45.0 + 1e-6
Inside the algorithm: a second-order solver of the Saramito model
=================================================================
def solve_saramito_evp_1d(
t_grid: np.ndarray,
forcing_fn: Callable[[float], float],
G0: float = 100.0,
tau_y: float = 15.0,
eta_p: float = 5.0,
eta_s: float = 0.5,
mode: str = "stress_controlled",
) -> dict:
"""The elastoviscoplastic model of Saramito (2007) in homogeneous shear, with imposed stress or imposed rate."""
t = np.asarray(t_grid, dtype=float).ravel()
if t.size < 2 or np.any(np.diff(t) <= 0.0) or G0 <= 0.0 or tau_y < 0.0 or eta_p <= 0.0 or eta_s <= 0.0:
raise ValueError("Require increasing t_grid and positive G0, eta_p, eta_s (tau_y >= 0).")
if mode not in ("stress_controlled", "rate_controlled"):
raise ValueError("mode must be 'stress_controlled' or 'rate_controlled'.")
lam = eta_p / G0
tau_xx = 0.0
tau_xy = 0.0
strain = 0.0
stress_tot = np.zeros_like(t)
tau_p_hist = np.zeros_like(t)
gdot_hist = np.zeros_like(t)
strain_hist = np.zeros_like(t)
yielded = np.zeros(t.size, dtype=bool)
def _von_mises_2d(txx: float, txy: float) -> float:
# Deviatoric second invariant norm ||tau_d|| = sqrt(txx^2 / 2 + txy^2) so pure shear txx=0 gives |txy|:
return math.sqrt(0.5 * txx * txx + txy * txy)
for k in range(t.size):
tk = float(t[k])
f_in = float(forcing_fn(tk))
gdot_cur = (f_in - tau_xy) / eta_s if mode == "stress_controlled" else f_in
sig_cur = f_in if mode == "stress_controlled" else tau_xy + eta_s * gdot_cur
vm = _von_mises_2d(tau_xx, tau_xy)
stress_tot[k] = sig_cur
tau_p_hist[k] = tau_xy
gdot_hist[k] = gdot_cur
strain_hist[k] = strain
yielded[k] = vm > tau_y + 1e-12
if k == t.size - 1:
break
dt = float(t[k + 1] - t[k])
def _rhs(txx: float, txy: float, t_eval: float) -> tuple[float, float, float]:
fin = float(forcing_fn(t_eval))
gd = (fin - txy) / eta_s if mode == "stress_controlled" else fin
tnorm = _von_mises_2d(txx, txy)
y_fac = max(0.0, (tnorm - tau_y) / max(tnorm, 1e-15))
d_txx = 2.0 * gd * txy - (y_fac / lam) * txx
d_txy = G0 * gd - (y_fac / lam) * txy
return d_txx, d_txy, gd
k1_xx, k1_xy, g1 = _rhs(tau_xx, tau_xy, tk)
k2_xx, k2_xy, g2 = _rhs(tau_xx + 0.5 * dt * k1_xx, tau_xy + 0.5 * dt * k1_xy, tk + 0.5 * dt)
tau_xx += dt * k2_xx
tau_xy += dt * k2_xy
strain += dt * g2
return {
"t": t,
"stress": stress_tot,
"tau_p": tau_p_hist,
"shear_rate": gdot_hist,
"strain": strain_hist,
"yielded_mask": yielded,
}
Max |this solver - package| strain error = 0.000e+00, stress error = 0.000e+00
Final residual von Mises stress after unloading = 10.346 Pa <= tau_y = 45.0 Pa
Exercises¶
Worked solutions are in 11_solutions.ipynb. The cell below the list is a short self-check to start from.
Verify a result. Derive the strain of the Saramito model for a stress of , below the yield stress , applied for and removed for (assumed parameters
CARBOPOL_EVP). Below the yield stress the model is a Kelvin–Voigt solid. Compare with the numerical solution, and check that no strain remains after unloading.Find how it fails. Compare the Saramito model (
CARBOPOL_EVP: ) with a Bingham model without elasticity for a pulse of stress of the kind applied in a dispensing nozzle: for , then until . Compute the strain that is recovered after the stress is removed and the most negative shear rate.Implement it yourself. Write
solve_channel_saramito_evp_1d(ny, H_half, dpdz_fn, t_grid, G0, tau_y, eta_p, eta_s)in NumPy for flow without inertia in a plane channel, , with the shear stress and the velocity . Use the parametersCARBOPOL_EVPwith and (a wall stress of ) for and afterwards. Check that the yield surface is at and that the centreline velocity is negative after the pressure gradient is removed.
heading("Self-check for the exercises")
assert np.isclose(evp_sub["strain"][-1], gamma_hooke_exact, rtol=1e-5)
assert min(overshoot_ratios) > 1.08 and peak_stresses[0] < peak_stresses[2]
assert np.isclose(norm_dissip[0], 1.0, rtol=0.03) and norm_dissip[2] > 6.0 * norm_dissip[0]
assert recoil_strains[0] > recoil_strains[1] > recoil_strains[2]
assert err_gam < 1e-14 and err_txy < 1e-13
print("All checks passed.")
Self-check for the exercises
============================
All checks passed.