Algorithmadvanced
Arc-length method
Also called Riks method, Crisfield method.
Traces nonlinear equilibrium paths through limit points by constraining the step length in load and displacement space together.
- Time
- Θ(s j n b^2) worst
- Space
- Θ(n b) extra
- Where
- b = the half bandwidth of the tangent stiffness; j = the number of Newton iterations per step; n = the number of unknowns; s = the number of arc-length steps
- Model
- Real RAM
- Properties
- deterministiciterativepasses limit pointspasses snap back
- Evidence
- Proof sketchCode in 1 languages
- Origin
- E. Riks, G. A. Wempner, M. A. Crisfield, 1979
The arc-length method follows the equilibrium path of a nonlinear structure, , as the load factor and the displacements change together. Plain load control fixes and solves for with Newton's method, so it fails at a limit point, where the load reaches a maximum and the tangent stiffness becomes singular. The arc-length method treats as an unknown and adds one scalar equation: each step must move a fixed distance along the path, measured in the combined space of displacement and load. With this constraint the bordered system stays regular at limit points, so the method passes through snap-through, where the load falls after a peak, and snap-back, where the displacement also turns back.
In plain words
Push down on the top of a shallow arch. At first it resists more and more, then at some point it gives way and jumps through to the other side. A computer that raises the push in fixed amounts cannot follow what happens after the peak, because no nearby position can carry a larger push. The arc-length method does not choose the push in advance. It asks for the next state to be a fixed distance away along the curve of all balanced states, where the distance counts both the movement and the change in push. So it can go over the top of the curve, follow it down while the arch gives way, and come back up on the other side.
The problem
Input. An internal force and its tangent stiffness , a fixed load pattern , a start point on the path, an arc length , a scale for the load term, a tolerance and a number of steps .
Output. Points , , with tol, such that each increment satisfies
and the points follow the path forward (no increment turns back against the previous one).
The constraint with is the spherical form. With it is the cylindrical form of Crisfield, which measures only the displacement and is not affected by the units of the load.
The algorithm
ARC-LENGTH(f_int, K_T, P, u_0, lambda_0, dl, psi, s)- 1
(u, lambda) <- (u_0, lambda_0) - 2
repeat s times - 3
solve K_T(u) u_t = P ▷ tangent direction - 4
Dlambda <- ± dl / sqrt(u_t . u_t + psi^2 P . P); Du <- Dlambda u_t ▷ sign: same way as the last step - 5
loop - 6
g <- f_int(u + Du) - (lambda + Dlambda) P; if |g| <= tol then exit loop - 7
solve K_T(u + Du) [u_r, u_t] = [-g, P] - 8
choose the root d of |Du + u_r + d u_t|^2 + psi^2 (Dlambda + d)^2 P . P = dl^2 that keeps the step direction - 9
Du <- Du + u_r + d u_t; Dlambda <- Dlambda + d - 10
(u, lambda) <- (u + Du, lambda + Dlambda); record the point - 11
return the recorded points
The quadratic of line L8. With the constraint is with
Of the two roots, take the one for which the new increment has the larger inner product with the old one (Crisfield 1981). The other root usually sends the step back to the point it came from. If the roots are not real, the step is too long for the local curvature: halve and repeat the step. The reference code does this.
Riks variant. In place of the quadratic, use the linear condition that the correction is normal to the predictor, . Then each iteration is Newton's method on the bordered system of equations, and no root has to be chosen.
Example
The two-bar truss. Two bars of axial stiffness go from to the apex , with a downward load at the apex. Let be the downward displacement of the apex, , and . The vertical force of the two bars is
At , . The load has a maximum where , at with . For larger loads there is no equilibrium near the start, so load control fails there. The apex then snaps through: the force is zero again at (both bars horizontal), negative down to at , zero at (the mirror image of the start), and rising after that.
The first step. With and , line L3 gives and line L4 gives and . The residual of line L6 is , because the path bends below its tangent. Two corrections bring the residual below , at , .
The whole path. Twelve steps with give the points below. The reference code records them, and each needs two Newton corrections.
| step | step | ||||
|---|---|---|---|---|---|
| 1 | 0.0964 | 0.02655 | 7 | 0.6897 | -0.03341 |
| 2 | 0.1958 | 0.03789 | 8 | 0.7896 | -0.03829 |
| 3 | 0.2957 | 0.03487 | 9 | 0.8892 | -0.02918 |
| 4 | 0.3948 | 0.02106 | 10 | 0.9861 | -0.00479 |
| 5 | 0.4928 | 0.00151 | 11 | 1.0786 | 0.03339 |
| 6 | 0.5908 | -0.01843 | 12 | 1.1657 | 0.08253 |
The steps pass the maximum between steps 2 and 3 and the minimum near step 8 with no special treatment. The largest sampled load misses the exact peak by : the measured gaps are , and for , and .
Snap-back. Put a spring of stiffness between the apex and the loaded point. Then the loaded point moves . The truss softens with a slope down to at , which is steeper than , so on part of the path decreases while the path goes on. Load control and control by both fail there. The arc-length method with two unknowns follows the whole curve (test_snap_back_with_a_soft_spring).
Correctness
The proofs are in the correctness proof.
- Each recorded point is in equilibrium (theorem). Line L10 is reached only after the test of line L6 succeeds.
- The constraint holds exactly at every iterate (theorem). The predictor of line L4 satisfies it by its choice of , and line L9 adds a correction whose is a root of the constraint quadratic.
- The bordered system is regular at a limit point (theorem). At a point where is singular with a one-dimensional null space spanned by , and (a limit point, not a bifurcation point), the matrix of the equilibrium equations and the linearized constraint is nonsingular when the step direction is not orthogonal to the path tangent. So the Riks iteration is Newton's method on a regular system and converges locally quadratically. For Crisfield's quadratic form the local convergence is a standard result (Crisfield 1981) that the proof only sketches.
- The method cannot be trusted at a bifurcation point. If , the bordered matrix is singular at the point for every constraint, and the steps may follow either branch without warning.
Proof: The arc-length steps keep the constraint, and the bordered system is regular at limit pointspartial
Setting. is twice continuously differentiable with tangent , is fixed, and . The equilibrium path is the set where . A point of the path is regular if the matrix has rank . Near a regular point the path is a smooth curve by the implicit function theorem, and its tangent spans the null space of . The status is partial because the local convergence of Crisfield's quadratic form is only sketched (Remark 6).
Lemma 1 (recorded points are in equilibrium). Every point recorded at line L10 satisfies tol.
Proof. The loop of line L5 exits only through the test of line L6, which checks this inequality for , and line L10 records exactly this pair. In the reference code a step whose loop ends in another way is not recorded; it is repeated with half the arc length.
Lemma 2 (the predictor). If is nonsingular, line L3 gives the tangent of the path at , and the increment of line L4 satisfies .
Proof. means , so spans the null space, which is the tangent direction. With the left side of the constraint is , which is for .
Lemma 3 (the corrector keeps the constraint). Let satisfy the constraint or not, and let , be the solutions of line L7. For every real root of with the coefficients of the page, the new increment satisfies the constraint exactly. It also satisfies the linearized equilibrium equation: .
Proof. Put . Then , which is zero at a root. For the second claim, and , so .
So every iterate, and hence every recorded increment, lies exactly on the sphere (or cylinder for ) of radius around the last converged point. The reference test test_arc_length_constraint_holds_for_each_step checks this to .
Lemma 4 (the bordered matrix). Let be a regular point of the path with tangent , and let . The matrix
is nonsingular exactly when .
Proof. Since has rank , its null space is spanned by . If for , then , so , and the last row gives . If , then and , so is nonsingular. If , then and is singular.
Corollary 5 (limit points). Let be a point where has a one-dimensional null space spanned by and (here is symmetric, as for a conservative internal force). Then the point is regular, its tangent is , and the bordered matrix of the Riks iteration, with from the predictor, is nonsingular as long as .
Proof. The range of is the orthogonal complement of , and is not in it because . So the columns of span , and the point is regular. gives , so the tangent is : at a limit point the load is stationary. Lemma 4 with gives the last claim.
The Riks iteration solves together with the linear constraint by Newton's method, and the Jacobian of this system of equations is with . When the predictor is close enough to the path, is close to a multiple of , so . By Lemma 4, is nonsingular near the solution, and the standard local theorem for Newton's method for systems (for example the Kantorovich theorem) gives local quadratic convergence, at limit points as well as at ordinary points. Load control is the case , and at a limit point. So by Lemma 4 its bordered matrix is singular there, which is why load control fails.
Bifurcation points. If , then has rank at the point, the point is not regular, and is singular for every . Lemma 4 does not apply, and the method gives no guarantee about which branch it follows.
Remark 6 (Crisfield's quadratic form, sketch). Crisfield's iteration replaces the linear constraint by the exact sphere and picks the root that keeps the direction of the increment. Near a regular point on the path the two roots are well separated: one is close to the Newton correction of the Riks form, the other moves the increment to the opposite side of the sphere, where its inner product with the old increment is negative. With the rule of line L8, each iteration differs from a Newton step on the bordered system by a term of second order in the correction, so local convergence follows as for Newton's method. Crisfield (1981) gives the method and its use on snap-through problems. We do not give a full proof here.
Lemma 7 (the limit point of the two-bar truss). For with , and , the load has a stationary point at with .
Proof. With , , so . This is zero at . At it is , and at it is . It is monotone in , hence in , so there is exactly one zero in . Since , the load rises with from to this point and falls after it.
For and this gives and the limit load , which the reference test test_limit_load_against_closed_form compares with the arc-length path.
Complexity
In the real-RAM model, each Newton iteration assembles and factors it once. For a banded matrix with half bandwidth this costs . The two right sides of line L7 share the factor and cost , and the quadratic costs . So steps with iterations each cost , the same as load control with the same number of iterations. The extra memory is one more vector of length , so for the factor. The number is a measurement, not a bound: it is 2 for the truss and at most 3 for the truss with a spring in the reference tests, with between 0.02 and 0.1. The reference code uses dense Gaussian elimination and is meant only for small systems.
Properties
- One extra scalar unknown. The tangent matrix keeps its sparsity and symmetry, because line L7 solves with alone and the bordering is done by the two right sides.
- Works when is singular at isolated points, as at limit points, as long as the iterates do not land exactly on them.
- The step size is a length, not a load. Near a limit point the load changes little and the displacement a lot, so the method takes small load steps where they are needed without any rule for it.
- Sign of the predictor. The sign of at line L4 changes when the path passes a limit point. The rule "same direction as the last increment" handles this, while the rule "sign of " fails at bifurcation points.
Variants and improvements
- Riks normal plane and Ramm updated normal plane. Linearize the constraint about the predictor (Riks) or about the current iterate (Ramm). Then no quadratic root has to be chosen, at the price of a slightly different step length.
- Crisfield cylindrical () and spherical (). The cylindrical form is the default in many codes because the load and the displacement have different units.
- Adaptive arc length. Scale by the ratio of a target number of iterations to the actual number, for example .
- Local or indirect displacement control. For problems with localized damage, measure the arc length only on a few chosen degrees of freedom, such as a crack mouth opening.
- Pseudo-arclength continuation in numerical analysis. Keller's method is the same idea for general parameter dependent equations , with the normal plane constraint. See homotopy continuation for path following toward the roots of polynomial systems.
When to use it
Use it for quasi-static nonlinear structural problems where the load reaches a maximum or the response turns back: buckling of shallow shells and arches, snap-through of trusses, post-peak softening in concrete and composites, and contact problems with a load drop. When the load only increases, plain load control with Newton's method is simpler. When the path has a bifurcation, add a check of the sign and the number of negative pivots of , and perturb the structure or switch branches on purpose.
Pitfalls
- Wrong root. Choosing the root of line L8 by the smaller absolute value, or by sign, can send the path back on itself, which looks like a loop of converged points.
- Steps that are too long. Near a sharp turn of the path the quadratic has no real root, or Newton converges to a far part of the path. Halve the step and retry.
- Units in the spherical form. With the constraint adds a displacement squared and a load squared. If the load is in newtons and the displacements in metres, the load term dominates and the method behaves like load control. Scale or use the cylindrical form.
- Bifurcation is not a limit point. At a symmetric bifurcation , and the method passes the point on the primary path without noticing the secondary path. Monitor the number of negative pivots of .
- Path dependent materials. For plasticity or damage, the internal force depends on the history. Each step must start from the converged state of the last step, and the iterations within a step must not update the history. See the return mapping algorithm.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/arc-length-method/. The authors are listed in prov/J4J4WD.jsonl.
"""Arc-length continuation (Riks 1979, Crisfield 1981) for f_int(u) = lam P.
The unknowns are the displacements u (a list) and the load factor lam. Each
step moves a distance dl along the equilibrium path, measured by
|Du|^2 + psi^2 Dlam^2 |P|^2 = dl^2,
and corrects with Newton iterations that keep this constraint (Crisfield's
spherical form; psi = 0 gives the cylindrical form). Matrices are lists of
rows, as in scimat.
"""
import math
import scimat
def arc_length(fint, tangent, P, u0, dl, nsteps, psi=1.0, tol=1e-10, maxit=25, lam0=0.0):
"""Trace the equilibrium path of fint(u) = lam P from (u0, lam0).
tangent(u) returns d fint / d u. Return a list of (u, lam, iterations), the
start point included. A step whose quadratic has no real root, or whose
Newton iteration does not converge, is retried with half the arc length.
"""
n = len(u0)
pp = scimat.dot(P, P)
u, lam = list(u0), lam0 # @line L1
path = [(list(u), lam, 0)]
prev = None # previous increment (Du, Dlam)
step = 0
length = dl
while step < nsteps: # @line L2
ut = scimat.solve(tangent(u), P) # @line L3
dlam = length / math.sqrt(scimat.dot(ut, ut) + psi * psi * pp)
if prev is not None and scimat.dot(prev[0], ut) + psi * psi * prev[1] * pp < 0:
dlam = -dlam # keep going forward along the path
du = scimat.scale(dlam, ut) # @line L4
ok = False
for it in range(maxit): # @line L5
g = scimat.sub(fint(scimat.add(u, du)), scimat.scale(lam + dlam, P)) # @line L6
if scimat.norm2(g) <= tol * (1 + abs(lam + dlam) * math.sqrt(pp)):
ok = True
break
kt = tangent(scimat.add(u, du))
sol = scimat.solve(kt, [[-gi, pi] for gi, pi in zip(g, P)]) # @line L7
ur = [row[0] for row in sol]
ut = [row[1] for row in sol]
root = _constraint_root(du, dlam, ur, ut, pp, psi, length) # @line L8
if root is None:
break
du = [du[i] + ur[i] + root * ut[i] for i in range(n)] # @line L9
dlam += root
if not ok:
length /= 2
if length < dl * 1e-6:
raise RuntimeError("arc-length step failed")
continue
u = scimat.add(u, du) # @line L10
lam += dlam
prev = (du, dlam)
path.append((list(u), lam, it))
step += 1
length = dl
return path # @line L11
def _constraint_root(du, dlam, ur, ut, pp, psi, length):
"""Return the correction dmu of the load factor that keeps the arc length.
The new increment is du + ur + dmu ut. Of the two roots of the quadratic,
take the one whose new increment makes the smaller angle with du (Crisfield).
Return None if the roots are not real.
"""
w = scimat.add(du, ur)
a = scimat.dot(ut, ut) + psi * psi * pp
b = 2 * (scimat.dot(ut, w) + psi * psi * dlam * pp)
c = scimat.dot(w, w) + psi * psi * dlam * dlam * pp - length * length
disc = b * b - 4 * a * c
if disc < 0:
return None
s = math.sqrt(disc)
# stable formulas for the two roots
q = -(b + math.copysign(s, b)) / 2
roots = [q / a, c / q] if q != 0 else [0.0, 0.0]
def cosine(mu):
new = [w[i] + mu * ut[i] for i in range(len(w))]
return scimat.dot(new, du) + psi * psi * (dlam + mu) * dlam * pp
return max(roots, key=cosine)
def load_control(fint, tangent, P, u0, lams, tol=1e-10, maxit=50):
"""Newton's method at each prescribed load factor in lams, from the last solution.
Return a list of (u, lam, iterations). Raise RuntimeError if Newton does not converge.
"""
u = list(u0)
out = []
for lam in lams:
for it in range(maxit):
g = scimat.sub(fint(u), scimat.scale(lam, P))
if scimat.norm2(g) <= tol * (1 + abs(lam) * scimat.norm2(P)):
break
u = scimat.sub(u, scimat.solve(tangent(u), g))
else:
raise RuntimeError("Newton did not converge at lam = %r" % lam)
out.append((list(u), lam, it))
return out
def von_mises_truss(EA=1.0, L=1.0, H=0.5):
"""Return (fint, tangent) of the symmetric two-bar truss with one degree of freedom.
The bars go from (-L, 0) and (L, 0) to the apex (0, H). u = [w] is the
downward displacement of the apex, and fint is the upward resisting force
2 EA y (1/l - 1/l0) with y = H - w, l = sqrt(L^2 + y^2), l0 = sqrt(L^2 + H^2).
"""
l0 = math.hypot(L, H)
def fint(u):
y = H - u[0]
l = math.hypot(L, y)
return [2 * EA * y * (1 / l - 1 / l0)]
def tangent(u):
y = H - u[0]
l = math.hypot(L, y)
return [[-2 * EA * (L * L / l ** 3 - 1 / l0)]]
return fint, tangent
def von_mises_limit_point(EA=1.0, L=1.0, H=0.5):
"""Return (w, load) at the first limit point of the truss, in closed form.
d fint / d y = 2 EA (L^2 / l^3 - 1 / l0) is zero at l^3 = L^2 l0.
"""
l0 = math.hypot(L, H)
l = (L * L * l0) ** (1 / 3)
y = math.sqrt(l * l - L * L)
return H - y, 2 * EA * y * (1 / l - 1 / l0)
def truss_with_spring(k, EA=1.0, L=1.0, H=0.5):
"""Return (fint, tangent) of the truss loaded through a vertical spring of stiffness k.
u = [w, z]: w is the apex displacement and z the displacement of the loaded
end of the spring, both downward. The load acts on z, so P = [0, 1].
The path has a snap-back in z when k is smaller than the largest softening slope.
"""
f1, t1 = von_mises_truss(EA, L, H)
def fint(u):
s = k * (u[1] - u[0])
return [f1([u[0]])[0] - s, s]
def tangent(u):
kt = t1([u[0]])[0][0]
return [[kt + k, -k], [-k, k]]
return fint, tangent
scimat.py 227 lines
# SPDX-License-Identifier: MIT
# Shared helper of the scientific-computing pages of https://algorithm.tamnd.com/. The authors are listed in prov/.
"""Small dense linear algebra and error norms for the scientific-computing pages.
A matrix is a list of rows and a vector is a list. Entries may be int,
float or fractions.Fraction. The routines that do not take a square root
(solve, inv, det and the arithmetic) keep Fraction entries exact.
cholesky, cholesky_solve and norm2 take square roots and return floats.
API (fixed; other pages copy this file byte for byte):
zeros(m, n=None) m by n zero matrix (n = m if not given)
eye(n) n by n identity
add(A, B), sub(A, B) entrywise sum and difference (vectors or matrices)
scale(c, A) c times A (vector or matrix)
matmul(A, B) matrix product
matvec(A, x) matrix times vector
transpose(A) transpose
dot(x, y) inner product of two vectors
norm2(x) Euclidean norm of a vector, as a float
outer(x, y) outer product x y^T
solve(A, b) Gaussian elimination with partial pivoting;
b is a vector or a matrix of right sides
inv(A) inverse of A
det(A) determinant of A
cholesky(A) lower triangular L with A = L L^T (floats)
cholesky_solve(L, b) solve L L^T x = b for a vector b
err_l1(e, dx=1) sum |e_j| dx
err_l2(e, dx=1) sqrt(sum e_j^2 dx), as a float
err_linf(e, dx=1) max |e_j| (dx is not used)
observed_order(errors) [log2(E_i / E_(i+1)) for successive errors]
"""
import math
def zeros(m, n=None):
"""Return an m by n matrix of zeros (n = m if n is None)."""
if n is None:
n = m
return [[0] * n for _ in range(m)]
def eye(n):
"""Return the n by n identity matrix."""
out = zeros(n, n)
for i in range(n):
out[i][i] = 1
return out
def _is_matrix(a):
return len(a) > 0 and isinstance(a[0], list)
def add(a, b):
"""Return a + b for two vectors or two matrices of the same shape."""
if _is_matrix(a):
return [[x + y for x, y in zip(ra, rb)] for ra, rb in zip(a, b)]
return [x + y for x, y in zip(a, b)]
def sub(a, b):
"""Return a - b for two vectors or two matrices of the same shape."""
if _is_matrix(a):
return [[x - y for x, y in zip(ra, rb)] for ra, rb in zip(a, b)]
return [x - y for x, y in zip(a, b)]
def scale(c, a):
"""Return c times a, for a vector or a matrix a."""
if _is_matrix(a):
return [[c * x for x in row] for row in a]
return [c * x for x in a]
def transpose(a):
"""Return the transpose of the matrix a."""
return [list(col) for col in zip(*a)]
def matmul(a, b):
"""Return the matrix product a b."""
bt = transpose(b)
return [[sum(x * y for x, y in zip(row, col)) for col in bt] for row in a]
def matvec(a, x):
"""Return the product of the matrix a and the vector x."""
return [sum(aij * xj for aij, xj in zip(row, x)) for row in a]
def dot(x, y):
"""Return the inner product of the vectors x and y."""
return sum(a * b for a, b in zip(x, y))
def norm2(x):
"""Return the Euclidean norm of the vector x, as a float."""
return math.sqrt(float(dot(x, x)))
def outer(x, y):
"""Return the outer product x y^T as a matrix."""
return [[a * b for b in y] for a in x]
def _eliminate(a, rhs):
"""Reduce a to upper triangular form with partial pivoting.
a is a copy of the square matrix, rhs a list of right side rows (one
row per row of a) that receives the same row operations. Return the
number of row swaps. Raise ValueError if a pivot is zero.
"""
n = len(a)
swaps = 0
for k in range(n):
p = max(range(k, n), key=lambda i: abs(a[i][k]))
if a[p][k] == 0:
raise ValueError("matrix is singular")
if p != k:
a[k], a[p] = a[p], a[k]
rhs[k], rhs[p] = rhs[p], rhs[k]
swaps += 1
for i in range(k + 1, n):
f = a[i][k] / a[k][k]
if f == 0:
continue
for j in range(k, n):
a[i][j] -= f * a[k][j]
for j in range(len(rhs[i])):
rhs[i][j] -= f * rhs[k][j]
return swaps
def solve(a, b):
"""Solve a x = b by Gaussian elimination with partial pivoting.
b is a vector (the result is a vector) or a matrix with one column per
right side (the result is a matrix). Fraction entries stay exact.
Raise ValueError if a is singular.
"""
n = len(a)
work = [list(row) for row in a]
vector = not _is_matrix(b)
rhs = [[v] for v in b] if vector else [list(row) for row in b]
_eliminate(work, rhs)
m = len(rhs[0]) if n else 0
x = [[0] * m for _ in range(n)]
for i in range(n - 1, -1, -1):
for j in range(m):
s = rhs[i][j]
for k in range(i + 1, n):
s -= work[i][k] * x[k][j]
x[i][j] = s / work[i][i]
if vector:
return [row[0] for row in x]
return x
def inv(a):
"""Return the inverse of the square matrix a."""
return solve(a, eye(len(a)))
def det(a):
"""Return the determinant of the square matrix a (0 if singular)."""
work = [list(row) for row in a]
rhs = [[] for _ in a]
try:
swaps = _eliminate(work, rhs)
except ValueError:
return 0
d = -1 if swaps % 2 else 1
for i in range(len(a)):
d *= work[i][i]
return d
def cholesky(a):
"""Return the lower triangular L with a = L L^T, in floats.
Raise ValueError if a is not symmetric positive definite.
"""
n = len(a)
low = [[0.0] * n for _ in range(n)]
for j in range(n):
s = float(a[j][j]) - sum(low[j][k] ** 2 for k in range(j))
if s <= 0.0:
raise ValueError("matrix is not positive definite")
low[j][j] = math.sqrt(s)
for i in range(j + 1, n):
t = float(a[i][j]) - sum(low[i][k] * low[j][k] for k in range(j))
low[i][j] = t / low[j][j]
return low
def cholesky_solve(low, b):
"""Solve L L^T x = b, with L from cholesky, for a vector b."""
n = len(low)
y = [0.0] * n
for i in range(n):
y[i] = (float(b[i]) - sum(low[i][k] * y[k] for k in range(i))) / low[i][i]
x = [0.0] * n
for i in range(n - 1, -1, -1):
x[i] = (y[i] - sum(low[k][i] * x[k] for k in range(i + 1, n))) / low[i][i]
return x
def err_l1(e, dx=1):
"""Return the discrete L1 norm sum |e_j| dx."""
return sum(abs(v) for v in e) * dx
def err_l2(e, dx=1):
"""Return the discrete L2 norm sqrt(sum e_j^2 dx), as a float."""
return math.sqrt(float(sum(v * v for v in e) * dx))
def err_linf(e, dx=1):
"""Return the max norm max |e_j|. dx is accepted for a uniform call and not used."""
return max(abs(v) for v in e)
def observed_order(errors):
"""Return [log2(E_i / E_(i+1))] for a list of errors on meshes h, h/2, h/4, ..."""
return [math.log2(float(errors[i]) / float(errors[i + 1])) for i in range(len(errors) - 1)]
test_arc_length_method.py 116 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/arc-length-method/. The authors are listed in prov/J4J4WD.jsonl.
import math
import scimat
from arc_length_method import (
arc_length,
load_control,
truss_with_spring,
von_mises_limit_point,
von_mises_truss,
)
def residual(fint, P, u, lam):
return scimat.norm2(scimat.sub(fint(u), scimat.scale(lam, P)))
def increments(path):
return [(scimat.sub(b[0], a[0]), b[1] - a[1]) for a, b in zip(path, path[1:])]
def test_linear_problem_is_a_straight_line():
K = [[4.0, -1.0], [-1.0, 3.0]]
P = [1.0, 2.0]
path = arc_length(lambda u: scimat.matvec(K, u), lambda u: K, P, [0.0, 0.0], 0.5, 6, psi=0.5)
x = scimat.solve(K, P)
for u, lam, it in path:
assert it == 0
assert all(abs(ui - lam * xi) < 1e-12 for ui, xi in zip(u, x))
for du, dlam in increments(path):
assert abs(scimat.dot(du, du) + 0.25 * dlam * dlam * scimat.dot(P, P) - 0.25) < 1e-12
def test_truss_path_through_the_limit_points():
fint, tangent = von_mises_truss()
path = arc_length(fint, tangent, [1.0], [0.0], 0.02, 70)
ws = [p[0][0] for p in path]
lams = [p[1] for p in path]
for u, lam, _ in path:
assert residual(fint, [1.0], u, lam) < 1e-9
# the apex moves down all the time, past the flat position w = H and the inverted one w = 2H
assert all(b > a for a, b in zip(ws, ws[1:]))
assert ws[-1] > 1.0
# the load rises, falls through zero and below, and rises again
i_max = max(range(len(lams)), key=lambda i: lams[i] if ws[i] < 0.5 else -1)
i_min = min(range(len(lams)), key=lambda i: lams[i])
assert 0 < i_max < i_min < len(lams) - 1
assert lams[i_min] < -0.03
assert lams[-1] > 0
def test_arc_length_constraint_holds_for_each_step():
fint, tangent = von_mises_truss()
for psi in (1.0, 0.0):
path = arc_length(fint, tangent, [1.0], [0.0], 0.03, 30, psi=psi)
for du, dlam in increments(path):
assert abs(scimat.dot(du, du) + psi * psi * dlam * dlam - 0.03 ** 2) < 1e-12
def test_limit_load_against_closed_form():
fint, tangent = von_mises_truss()
w_lim, p_lim = von_mises_limit_point()
# the closed form is a stationary point of fint
h = 1e-6
assert abs(fint([w_lim + h])[0] - fint([w_lim - h])[0]) < 1e-12
errs = []
for dl in (0.04, 0.02, 0.01):
path = arc_length(fint, tangent, [1.0], [0.0], dl, int(0.6 / dl))
best = max(p[1] for p in path if p[0][0] < 0.5)
assert best <= p_lim + 1e-12
errs.append(p_lim - best)
# the largest sampled load misses the peak by O(dl^2)
assert errs[-1] < 1e-5
assert all(q > 1.5 for q in scimat.observed_order(errs))
def test_load_control_cannot_pass_the_limit_point():
fint, tangent = von_mises_truss()
w_lim, p_lim = von_mises_limit_point()
below = load_control(fint, tangent, [1.0], [0.0], [p_lim * s for s in (0.25, 0.5, 0.75, 0.95)])
assert below[-1][0][0] < w_lim
# just above the limit load there is no equilibrium near the start branch:
# Newton either fails or jumps through to the far branch beyond w = 2H.
try:
out = load_control(fint, tangent, [1.0], below[-1][0], [1.05 * p_lim])
except RuntimeError:
return
assert out[-1][0][0] > 1.0
def test_snap_back_with_a_soft_spring():
# Load on the free end of a spring of stiffness 0.1 on top of the apex.
# The truss softens faster than the spring is stiff, so the loaded point moves back.
k = 0.1
fint, tangent = truss_with_spring(k)
P = [0.0, 1.0]
path = arc_length(fint, tangent, P, [0.0, 0.0], 0.05, 80)
zs = [p[0][1] for p in path]
for u, lam, _ in path:
assert residual(fint, P, u, lam) < 1e-9
assert abs(k * (u[1] - u[0]) - lam) < 1e-9
backs = sum(1 for a, b in zip(zs, zs[1:]) if b < a)
assert backs >= 3
assert path[-1][0][0] > 1.0
# successive increments never point backwards along the path
inc = increments(path)
for (a, la), (b, lb) in zip(inc, inc[1:]):
assert scimat.dot(a, b) + la * lb > 0
def test_iterations_are_few():
fint, tangent = truss_with_spring(0.1)
path = arc_length(fint, tangent, [0.0, 1.0], [0.0, 0.0], 0.05, 80)
assert max(p[2] for p in path) <= 6
History
Wempner in 1971 used the arc length of the equilibrium path as a parameter for nonlinear structural problems. Riks in 1979 gave an incremental method that adds the arc-length constraint and solves with Newton corrections normal to the predictor, for snapping and buckling problems. Crisfield in 1981 gave the cylindrical form with a quadratic for the load correction and a rule to choose its root, and showed it on snap-through problems. Ramm in 1981 gave the updated normal plane variant. In numerical analysis Keller developed the same idea as pseudo-arclength continuation in 1977.
References
- E. Riks, An incremental approach to the solution of snapping and buckling problems, International Journal of Solids and Structures 15(7) (1979) 529-551, the arc-length constraint on the load and displacement increment, with the linearized (normal plane) correction
- M. A. Crisfield, A fast incremental/iterative solution procedure that handles snap-through, Computers and Structures 13(1-3) (1981) 55-62, the cylindrical arc-length constraint, the quadratic for the load correction and the choice of its root
- G. A. Wempner, Discrete approximations related to nonlinear theories of solids, International Journal of Solids and Structures 7(11) (1971) 1581-1599, the arc length as a path parameter for nonlinear structural problems
- Ted Belytschko, Wing Kam Liu and Brian Moran, Nonlinear Finite Elements for Continua and Structures, Wiley, 2000, Chapter 6 (solution methods for equilibrium problems, load and arc-length continuation)
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag J4J4WD Edit this page History Report an error Markdown