structsolve 0.10.0__tar.gz → 0.12.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. {structsolve-0.10.0/structsolve.egg-info → structsolve-0.12.0}/PKG-INFO +27 -4
  2. {structsolve-0.10.0 → structsolve-0.12.0}/README.md +26 -3
  3. {structsolve-0.10.0 → structsolve-0.12.0}/pyproject.toml +1 -1
  4. {structsolve-0.10.0 → structsolve-0.12.0}/structsolve/analysis.py +52 -4
  5. {structsolve-0.10.0 → structsolve-0.12.0}/structsolve/arc_length.py +113 -43
  6. {structsolve-0.10.0 → structsolve-0.12.0}/structsolve/arpackutils.py +25 -2
  7. {structsolve-0.10.0 → structsolve-0.12.0}/structsolve/callbacks.py +26 -2
  8. {structsolve-0.10.0 → structsolve-0.12.0}/structsolve/convergence.py +24 -8
  9. {structsolve-0.10.0 → structsolve-0.12.0}/structsolve/freq.py +349 -54
  10. {structsolve-0.10.0 → structsolve-0.12.0}/structsolve/linear_buckling.py +175 -60
  11. {structsolve-0.10.0 → structsolve-0.12.0}/structsolve/newton_raphson.py +50 -25
  12. {structsolve-0.10.0 → structsolve-0.12.0}/structsolve/pardiso.py +124 -7
  13. {structsolve-0.10.0 → structsolve-0.12.0}/structsolve/sparseutils.py +3 -2
  14. {structsolve-0.10.0 → structsolve-0.12.0}/structsolve/static.py +49 -12
  15. {structsolve-0.10.0 → structsolve-0.12.0}/structsolve/stopping.py +3 -0
  16. {structsolve-0.10.0 → structsolve-0.12.0/structsolve.egg-info}/PKG-INFO +27 -4
  17. {structsolve-0.10.0 → structsolve-0.12.0}/structsolve.egg-info/SOURCES.txt +1 -0
  18. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_arc_length.py +21 -3
  19. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_arc_length_fung_kaplan.py +80 -25
  20. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_arc_length_robustness.py +2 -2
  21. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_arpackutils.py +20 -3
  22. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_branch_switching.py +7 -3
  23. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_follower_freq_static.py +17 -2
  24. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_follower_loads.py +19 -5
  25. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_freq.py +320 -16
  26. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_inertia_unsymmetric.py +12 -6
  27. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_linear_buckling.py +87 -27
  28. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_linear_buckling_unsymmetric.py +11 -9
  29. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_load_factor_dependent_load.py +18 -7
  30. structsolve-0.12.0/tests/test_on_converged.py +109 -0
  31. structsolve-0.12.0/tests/test_simo1990_cylinder.py +176 -0
  32. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_sparse_first.py +2 -3
  33. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_static_deflection.py +16 -4
  34. structsolve-0.10.0/tests/test_simo1990_cylinder.py +0 -124
  35. {structsolve-0.10.0 → structsolve-0.12.0}/LICENSE +0 -0
  36. {structsolve-0.10.0 → structsolve-0.12.0}/setup.cfg +0 -0
  37. {structsolve-0.10.0 → structsolve-0.12.0}/structsolve/__init__.py +0 -0
  38. {structsolve-0.10.0 → structsolve-0.12.0}/structsolve/arc_length_crisfield.py +0 -0
  39. {structsolve-0.10.0 → structsolve-0.12.0}/structsolve/arc_length_riks.py +0 -0
  40. {structsolve-0.10.0 → structsolve-0.12.0}/structsolve/displacement_control.py +0 -0
  41. {structsolve-0.10.0 → structsolve-0.12.0}/structsolve/generalized_displacement_control.py +0 -0
  42. {structsolve-0.10.0 → structsolve-0.12.0}/structsolve/logger.py +0 -0
  43. {structsolve-0.10.0 → structsolve-0.12.0}/structsolve.egg-info/dependency_links.txt +0 -0
  44. {structsolve-0.10.0 → structsolve-0.12.0}/structsolve.egg-info/requires.txt +0 -0
  45. {structsolve-0.10.0 → structsolve-0.12.0}/structsolve.egg-info/top_level.txt +0 -0
  46. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_analysis.py +0 -0
  47. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_arc_length_weights.py +0 -0
  48. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_constraint_values.py +0 -0
  49. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_constraint_values_load_factor.py +0 -0
  50. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_constraints.py +0 -0
  51. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_displacement_control.py +0 -0
  52. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_eigen_pardiso.py +0 -0
  53. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_factorization_cache.py +0 -0
  54. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_generalized_displacement_control.py +0 -0
  55. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_inertia.py +0 -0
  56. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_newton_raphson.py +0 -0
  57. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_pardiso.py +0 -0
  58. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_restart.py +0 -0
  59. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_reuse.py +0 -0
  60. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_sparseutils.py +0 -0
  61. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_static.py +0 -0
  62. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_stopping.py +0 -0
  63. {structsolve-0.10.0 → structsolve-0.12.0}/tests/test_warnings_registry.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: structsolve
3
- Version: 0.10.0
3
+ Version: 0.12.0
4
4
  Summary: Structural analysis solvers
5
5
  Author-email: "Saullo G. P. Castro" <castrosaullo@gmail.com>
6
6
  License-Expression: BSD-3-Clause
@@ -61,14 +61,28 @@ Structural analysis solvers tailored for semi-analytical models
61
61
  Currently these solvers are pretty much compatible with my other repository
62
62
  [panels](https://github.com/saullocastro/panels).
63
63
 
64
- The folder `notebooks/` holds validation notebooks against results of the
65
- literature, run with models of `panels`, see `notebooks/README.md`.
64
+
65
+ Running in the browser
66
+ ======================
67
+
68
+ `structsolve` is pure Python and runs in the browser with
69
+ [Pyodide](https://pyodide.org), which distributes NumPy and SciPy:
70
+
71
+ ```python
72
+ import micropip
73
+ await micropip.install("structsolve")
74
+ ```
75
+
76
+ There SciPy uses OpenBLAS: the cap of the `ncv` of ARPACK against the faulty
77
+ Intel MKL is not applied, `linear_solver='pardiso'` is not available (it calls
78
+ Intel oneMKL), and the reference cycles of SciPy's ARPACK wrappers are
79
+ collected after each call, so that the WebAssembly heap is not exhausted.
66
80
 
67
81
 
68
82
  Citing this library
69
83
  ===================
70
84
 
71
- Saullo G. P. Castro (2026). Structural analysis solvers tailored for semi-analytical models (Version 0.10.0). Zenodo. DOI: https://doi.org/10.5281/zenodo.2581212.
85
+ Saullo G. P. Castro (2026). Structural analysis solvers tailored for semi-analytical models (Version 0.12.0). Zenodo. DOI: https://doi.org/10.5281/zenodo.2581212.
72
86
 
73
87
 
74
88
  Documentation
@@ -83,6 +97,15 @@ History
83
97
 
84
98
  See [CHANGELOG.md](CHANGELOG.md) for the details of each version.
85
99
 
100
+ * version 0.12.0 (2026-11-23)
101
+ - `Analysis.on_converged`: a callable called once after every converged increment of the non-linear analyses, never for a rejected or cut increment, to update the internal variables of path-dependent models, e.g. the damage of a cohesive zone
102
+
103
+ * version 0.11.0 (2026-11-13)
104
+ - `freq` with the dense solvers (`sparse_solver=False`) solves the shifted inverse problem, accurate for the lowest natural frequencies of stiff models, e.g. with penalty springs, and warns when one of the lowest eigenpairs fails the residual check
105
+ - `freq` accepts the eigenpairs of the sparse solvers whose residual is at the round-off when the inertia of `K - s M` confirms the eigenvalue, instead of falling back to the dense solver or raising an error
106
+ - Arc-length methods: the final load factor is reached once, without a duplicated end point when the increments sum to it up to the round-off
107
+ - Every test runs in less than 30 s; the comparisons of the cylinder of Simo, Fox and Rifai (1990) with the literature are in the notebook `simo1990_cylinder_postbuckling`
108
+
86
109
  * version 0.10.0 (2026-11-03)
87
110
  - Arc-length corrections: line search and early divergence check; indirect displacement control and generalized displacement control; weights of the degrees of freedom in the arc-length norm
88
111
  - Stability along the path: the number of negative eigenvalues of the tangent with PARDISO (`linear_solver='pardiso'`, `inertia=True`), increments cut when it jumps (`max_inertia_jump`) and switching to the bifurcated branch along the critical eigenvector (`branch_switching`)
@@ -24,14 +24,28 @@ Structural analysis solvers tailored for semi-analytical models
24
24
  Currently these solvers are pretty much compatible with my other repository
25
25
  [panels](https://github.com/saullocastro/panels).
26
26
 
27
- The folder `notebooks/` holds validation notebooks against results of the
28
- literature, run with models of `panels`, see `notebooks/README.md`.
27
+
28
+ Running in the browser
29
+ ======================
30
+
31
+ `structsolve` is pure Python and runs in the browser with
32
+ [Pyodide](https://pyodide.org), which distributes NumPy and SciPy:
33
+
34
+ ```python
35
+ import micropip
36
+ await micropip.install("structsolve")
37
+ ```
38
+
39
+ There SciPy uses OpenBLAS: the cap of the `ncv` of ARPACK against the faulty
40
+ Intel MKL is not applied, `linear_solver='pardiso'` is not available (it calls
41
+ Intel oneMKL), and the reference cycles of SciPy's ARPACK wrappers are
42
+ collected after each call, so that the WebAssembly heap is not exhausted.
29
43
 
30
44
 
31
45
  Citing this library
32
46
  ===================
33
47
 
34
- Saullo G. P. Castro (2026). Structural analysis solvers tailored for semi-analytical models (Version 0.10.0). Zenodo. DOI: https://doi.org/10.5281/zenodo.2581212.
48
+ Saullo G. P. Castro (2026). Structural analysis solvers tailored for semi-analytical models (Version 0.12.0). Zenodo. DOI: https://doi.org/10.5281/zenodo.2581212.
35
49
 
36
50
 
37
51
  Documentation
@@ -46,6 +60,15 @@ History
46
60
 
47
61
  See [CHANGELOG.md](CHANGELOG.md) for the details of each version.
48
62
 
63
+ * version 0.12.0 (2026-11-23)
64
+ - `Analysis.on_converged`: a callable called once after every converged increment of the non-linear analyses, never for a rejected or cut increment, to update the internal variables of path-dependent models, e.g. the damage of a cohesive zone
65
+
66
+ * version 0.11.0 (2026-11-13)
67
+ - `freq` with the dense solvers (`sparse_solver=False`) solves the shifted inverse problem, accurate for the lowest natural frequencies of stiff models, e.g. with penalty springs, and warns when one of the lowest eigenpairs fails the residual check
68
+ - `freq` accepts the eigenpairs of the sparse solvers whose residual is at the round-off when the inertia of `K - s M` confirms the eigenvalue, instead of falling back to the dense solver or raising an error
69
+ - Arc-length methods: the final load factor is reached once, without a duplicated end point when the increments sum to it up to the round-off
70
+ - Every test runs in less than 30 s; the comparisons of the cylinder of Simo, Fox and Rifai (1990) with the literature are in the notebook `simo1990_cylinder_postbuckling`
71
+
49
72
  * version 0.10.0 (2026-11-03)
50
73
  - Arc-length corrections: line search and early divergence check; indirect displacement control and generalized displacement control; weights of the degrees of freedom in the arc-length norm
51
74
  - Stability along the path: the number of negative eigenvalues of the tangent with PARDISO (`linear_solver='pardiso'`, `inertia=True`), increments cut when it jumps (`max_inertia_jump`) and switching to the bifurcated branch along the critical eigenvector (`branch_switching`)
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "structsolve"
7
- version = "0.10.0"
7
+ version = "0.12.0"
8
8
  description = "Structural analysis solvers"
9
9
  readme = "README.md"
10
10
  license = "BSD-3-Clause"
@@ -182,6 +182,20 @@ class Analysis(object):
182
182
  increments beyond the first limit point or
183
183
  a displacement measure, see
184
184
  :mod:`.stopping`. Default is ``None``
185
+ ``on_converged`` ``callable``, ``on_converged(an)`` is
186
+ called once after every converged
187
+ increment of the non-linear analyses, when
188
+ ``an.cs[-1]`` and ``an.increments[-1]``
189
+ hold the new state, before
190
+ ``stop_criterion`` and before the next
191
+ increment starts, and never for an
192
+ increment that is rejected or cut, e.g. to
193
+ update the internal variables of a
194
+ path-dependent material, such as the
195
+ damage of a cohesive zone, which must only
196
+ change with converged states, see
197
+ :func:`.callbacks.converged`. Default is
198
+ ``None``
185
199
  ``final_load_factor`` ``float``, the load factor at which the
186
200
  non-linear analyses finish, exactly, or,
187
201
  for the arc-length and displacement control
@@ -233,9 +247,7 @@ class Analysis(object):
233
247
  and internal force vectors. Not used if
234
248
  ``None``. Default is ``1.e-9``, the tight
235
249
  tolerance of Crisfield's criterion with a
236
- consistent tangent; until version 0.8.0 the
237
- relative criterion was the only one, with the
238
- default ``1.e-6``
250
+ consistent tangent
239
251
  ``absTOL`` the convergence is also achieved when the
240
252
  maximum absolute residual force is smaller
241
253
  than this value, which depends on the units of
@@ -380,13 +392,28 @@ class Analysis(object):
380
392
  The tangent stiffness matrix may then be unsymmetric, which the solvers
381
393
  support, since they use LU factorizations.
382
394
 
395
+ Examples
396
+ --------
397
+ Linear static analysis of two uncoupled springs:
398
+
399
+ >>> import numpy as np
400
+ >>> from scipy.sparse import diags
401
+ >>> from structsolve import Analysis
402
+ >>> an = Analysis(
403
+ ... calc_fext=lambda inc=1., silent=False: np.array([2., 2.]),
404
+ ... calc_kC=lambda c=None, NLgeom=False, silent=False:
405
+ ... diags([2., 4.]).tocsr())
406
+ >>> increments, cs = an.static(silent=True)
407
+ >>> increments, cs[0]
408
+ ([1.0], array([1. , 0.5]))
409
+
383
410
  """
384
411
  __slots__ = ['NL_method', 'line_search', 'max_iter_line_search',
385
412
  'arc_length_line_search',
386
413
  'early_divergence', 'arc_length_weights', 'control_vector',
387
414
  'control_scale', 'linear_solver', 'inertia',
388
415
  'constraints', 'constraint_values', 'stop_criterion',
389
- 'final_load_factor',
416
+ 'on_converged', 'final_load_factor',
390
417
  'branch_switching', 'max_inertia_jump', 'inertia_num_eigvals',
391
418
  'restart_state', 'path_state', 'branch_points',
392
419
  'num_negative_eigvals', 'det_signs', 'num_perturbed_pivots',
@@ -415,6 +442,7 @@ class Analysis(object):
415
442
  self.constraints = None
416
443
  self.constraint_values = None
417
444
  self.stop_criterion = None
445
+ self.on_converged = None
418
446
  self.final_load_factor = 1.
419
447
  self.branch_switching = 0
420
448
  self.max_inertia_jump = None
@@ -527,6 +555,26 @@ class Analysis(object):
527
555
  multipliers `\lambda` of `(\boldsymbol{K}_C + \lambda \boldsymbol{K}_f) \boldsymbol{u} = \boldsymbol{0}`,
528
556
  including the negative and complex ones.
529
557
 
558
+ Examples
559
+ --------
560
+ Non-linear analysis of two hardening springs,
561
+ ``fint = k*c + c**3``, with the Newton-Raphson solver:
562
+
563
+ >>> import numpy as np
564
+ >>> from scipy.sparse import diags
565
+ >>> from structsolve import Analysis
566
+ >>> k = np.array([1., 2.])
567
+ >>> an = Analysis(
568
+ ... calc_fext=lambda inc=1., silent=False: np.array([2., 3.]),
569
+ ... calc_fint=lambda c, silent=False: k*c + c**3,
570
+ ... calc_kC=lambda c=None, NLgeom=False, silent=False:
571
+ ... diags(k + 3*c**2 if NLgeom else k).tocsr(),
572
+ ... calc_kG=lambda c=None, NLgeom=False, silent=False:
573
+ ... diags([0., 0.]).tocsr())
574
+ >>> increments, cs = an.static(NLgeom=True, silent=True)
575
+ >>> increments[-1], cs[-1].round(6)
576
+ (1.0, array([1., 1.]))
577
+
530
578
  """
531
579
  self.increments = []
532
580
  self.cs = []
@@ -33,6 +33,10 @@ MAX_GROWTH_FACTOR = 1.5
33
33
  MIN_GROWTH_FACTOR = 0.5
34
34
  #: Maximum number of converged steps of an arc-length analysis
35
35
  MAX_NUM_STEPS = 1000
36
+ #: Relative tolerance of the final load factor: a step that ends below
37
+ #: ``an.final_load_factor`` by less than this fraction of it, a round-off of
38
+ #: the sum of the increments, is corrected to it as a step that exceeds it
39
+ FINAL_LOAD_FACTOR_RTOL = 1e-12
36
40
  #: Factors tried in turn by the line search of the corrections, with
37
41
  #: ``Analysis.arc_length_line_search = True``
38
42
  LINE_SEARCH_ETAS = (1., 0.5, 0.25)
@@ -62,23 +66,67 @@ EIGVEC_MAX_SIZE = 64
62
66
 
63
67
  def _eigs_near_zero(solve_kT, size, p, start=None):
64
68
  r"""The ``p`` eigenvalues of `\boldsymbol{K}_T` closest to zero and their
65
- eigenvectors, by the subspace iteration of :func:`._critical_eigenvector`,
66
- with at most ``EIGVEC_MAX_ITER`` iterations, from the vectors ``start``,
67
- columns, completed by random vectors. With
68
- ``'pardiso'`` the solutions of the factorization are used without the
69
- check of their residual and GMRES, see :func:`.static._factorize`: the
70
- tangent stiffness matrix near a critical point is almost singular, the
71
- GMRES of its solutions took about one second each for the DOE09
72
- cylinder (57000 degrees of freedom), against 0.03 s for those of the
73
- factorization alone, and the subspace iteration converges to the
74
- eigenvectors closest to zero without them.
69
+ eigenvectors
70
+
71
+ Computed by a subspace iteration of ``p`` vectors with the solutions of
72
+ ``solve_kT``, at most ``EIGVEC_MAX_ITER`` iterations, until the
73
+ eigenvalues change by less than ``EIGVEC_TOL`` relative to the largest
74
+ `1/|\mu|`.
75
+
76
+ Parameters
77
+ ----------
78
+ solve_kT : callable
79
+ ``solve_kT(b)`` returns the solution ``x`` of `\boldsymbol{K}_T
80
+ \boldsymbol{x} = \boldsymbol{b}`, see :func:`.static._factorize`; its
81
+ attribute ``unrefined``, when present (``'pardiso'``), the solution
82
+ of the factorization without the check of its residual and GMRES, is
83
+ used instead.
84
+ size : int
85
+ Number of rows of `\boldsymbol{K}_T`.
86
+ p : int
87
+ Number of eigenpairs, the number of vectors of the subspace.
88
+ start : array-like or None, optional
89
+ Starting vectors, the columns, shape ``(size, q)``; the first
90
+ ``min(q, p)`` are used, completed by random vectors from a fixed
91
+ seed. ``None`` (default): only random vectors.
75
92
 
76
93
  Returns
77
94
  -------
78
95
  mus : array-like
79
- The eigenvalues, not sorted.
96
+ The eigenvalues, not sorted, shape ``(p',)``, ``p' <= p`` (a null
97
+ Ritz value of the inverse is dropped).
80
98
  vecs : array-like
81
- The eigenvectors, the columns, orthonormal.
99
+ The eigenvectors, the columns, orthonormal, shape ``(size, p')``.
100
+
101
+ Notes
102
+ -----
103
+ A variant of the subspace iteration of [1]_ (Section 11.6, p. 954), with
104
+ an identity mass matrix and the Rayleigh-Ritz projection applied to the
105
+ inverse: in each iteration the subspace `\boldsymbol{Y}` is
106
+ orthonormalized, `\boldsymbol{Y} = \boldsymbol{Q} \boldsymbol{R}`, then
107
+ multiplied by the inverse, `\boldsymbol{Y} \leftarrow
108
+ \boldsymbol{K}_T^{-1} \boldsymbol{Q}`, and the projected problem
109
+ `\boldsymbol{H} \boldsymbol{V} = \boldsymbol{V} \boldsymbol{\Theta}`,
110
+ `\boldsymbol{H} = \boldsymbol{Q}^\top \boldsymbol{K}_T^{-1}
111
+ \boldsymbol{Q}` (symmetrized), is solved. The Ritz values `\theta`
112
+ approximate the eigenvalues of largest modulus of
113
+ `\boldsymbol{K}_T^{-1}`, hence `\mu = 1/\theta` those of
114
+ `\boldsymbol{K}_T` closest to zero, with the eigenvectors
115
+ `\boldsymbol{Q} \boldsymbol{V}` in the Euclidean inner product. The
116
+ iteration stops when `|\theta - \theta_{old}| \le \epsilon \max
117
+ |\theta|` for every Ritz value, `\epsilon` = ``EIGVEC_TOL``.
118
+
119
+ The unrefined solutions of PARDISO are used because the tangent
120
+ stiffness matrix near a critical point is almost singular: the GMRES of
121
+ its solutions took about one second each for the DOE09 cylinder (57000
122
+ degrees of freedom), against 0.03 s for those of the factorization
123
+ alone, and the subspace iteration converges to the eigenvectors closest
124
+ to zero without them.
125
+
126
+ References
127
+ ----------
128
+ .. [1] Bathe, K.J., Finite Element Procedures, 2nd ed., K.J. Bathe,
129
+ Watertown, MA, 2014.
82
130
 
83
131
  """
84
132
  solve = getattr(solve_kT, 'unrefined', solve_kT)
@@ -107,32 +155,33 @@ def _critical_eigenvector(solve_kT, size, num_neg, num_new):
107
155
  r"""Eigenvector of the tangent stiffness matrix whose eigenvalue just
108
156
  became negative
109
157
 
110
- Subspace iteration with the inverse of the factorization ``solve_kT``,
111
- see :func:`.static._factorize`, and the Rayleigh-Ritz projection of the
112
- inverse on the orthonormalized subspace, which gives the eigenvalues of
113
- `\boldsymbol{K}_T` closest to zero and their eigenvectors in the
114
- Euclidean inner product, see :func:`._eigs_near_zero`. The subspace has
115
- ``num_neg + EIGVEC_NUM_GUARD`` vectors, ``num_neg`` being the number of
116
- negative eigenvalues of `\boldsymbol{K}_T`, and is iterated until the
117
- Ritz values change by less than ``EIGVEC_TOL``, at most
118
- ``EIGVEC_MAX_ITER`` times. When fewer than ``num_neg`` of the Ritz
119
- values are negative, i.e. positive eigenvalues are closer to zero than
120
- some negative ones, e.g. of weakly stiff terms of a Ritz model, the
121
- size of the subspace is doubled and the iteration repeated, up to
122
- ``EIGVEC_MAX_SIZE`` vectors. Without a count of negative eigenvalues
123
- (``'splu'``), ``num_neg`` is 1 when the determinant is negative and 0
124
- otherwise. With ``an.constraints`` the factorization
125
- is the bordered one, whose solutions satisfy the constraints, and the
126
- eigenpairs are those of `\boldsymbol{K}_T` restricted to them.
127
-
128
- Of the negative eigenvalues found, the ``num_new`` closest to zero are
129
- taken as those that became negative in the last step, and the most
130
- negative of them is the critical one, the first that became negative.
131
- Without negative eigenvalue, the one closest to zero is taken. With
132
- ``num_new < 0``, ``-num_new`` eigenvalues became positive in the last
133
- step, the subspace has ``-num_new`` more vectors, and the critical one
134
- is the largest of the ``-num_new`` smallest positive eigenvalues, the
135
- first that became positive.
158
+ The eigenpairs of `\boldsymbol{K}_T` closest to zero are computed with
159
+ :func:`._eigs_near_zero`, enough of them to hold the ``num_neg``
160
+ negative eigenvalues, up to ``EIGVEC_MAX_SIZE``. Of the negative
161
+ eigenvalues found, the ``num_new`` closest to zero are taken as those
162
+ that became negative in the last step, and the most negative of them is
163
+ the critical one, the first that became negative. Without negative
164
+ eigenvalue, the one closest to zero is taken. With ``num_new < 0``,
165
+ ``-num_new`` eigenvalues became positive in the last step, and the
166
+ critical one is the largest of the ``-num_new`` smallest positive
167
+ eigenvalues, the first that became positive.
168
+
169
+ Parameters
170
+ ----------
171
+ solve_kT : callable
172
+ Factorization of `\boldsymbol{K}_T` from :func:`.static._factorize`,
173
+ see :func:`._eigs_near_zero`. With ``an.constraints`` it is the
174
+ bordered one, whose solutions satisfy the constraints, and the
175
+ eigenpairs are those of `\boldsymbol{K}_T` restricted to them.
176
+ size : int
177
+ Number of rows of `\boldsymbol{K}_T`.
178
+ num_neg : int
179
+ Number of negative eigenvalues of `\boldsymbol{K}_T`; without a
180
+ count of negative eigenvalues (``'splu'``), 1 when the determinant
181
+ is negative and 0 otherwise.
182
+ num_new : int
183
+ Change of the number of negative eigenvalues in the last step,
184
+ negative when eigenvalues became positive.
136
185
 
137
186
  Returns
138
187
  -------
@@ -141,6 +190,17 @@ def _critical_eigenvector(solve_kT, size, num_neg, num_new):
141
190
  mu : float
142
191
  Its eigenvalue.
143
192
 
193
+ Notes
194
+ -----
195
+ The subspace iteration of :func:`._eigs_near_zero` starts with
196
+ ``num_neg + EIGVEC_NUM_GUARD`` vectors (at least ``1 +
197
+ EIGVEC_NUM_GUARD``), and ``-num_new`` more when ``num_new < 0``. When
198
+ fewer than ``num_neg`` of the Ritz values are negative, i.e. positive
199
+ eigenvalues are closer to zero than some negative ones, e.g. of weakly
200
+ stiff terms of a Ritz model, the size of the subspace is doubled and the
201
+ iteration repeated from the previous vectors, up to ``EIGVEC_MAX_SIZE``
202
+ vectors.
203
+
144
204
  """
145
205
  p = min(max(num_neg, 1) + max(-num_new, 0) + EIGVEC_NUM_GUARD, size)
146
206
  vecs = None
@@ -191,8 +251,9 @@ def _solver_arc_length(an, method, silent=False):
191
251
  The analysis stops when:
192
252
 
193
253
  - the load factor reaches ``an.final_load_factor``, 1.0 by default, the
194
- last solution being computed at exactly this load factor; never with
195
- ``an.final_load_factor = None``
254
+ last solution being computed at exactly this load factor, once: a step
255
+ ending below it by less than ``FINAL_LOAD_FACTOR_RTOL`` times it is
256
+ corrected to it; never with ``an.final_load_factor = None``
196
257
  - ``an.stop_criterion(an)`` returns ``True`` after a converged step, see
197
258
  :mod:`.stopping`
198
259
  - the cumulative arc length reaches ``an.maxArcLength``
@@ -724,9 +785,16 @@ def _solver_arc_length(an, method, silent=False):
724
785
  target = an.final_load_factor
725
786
 
726
787
  def target_reached(lbd0, dlbd0):
727
- # the step from lbd0 to lbd0 + dlbd0 exceeds the final load factor
728
- return (target is not None and lbd0 + dlbd0 > target
729
- and lbd0 < target)
788
+ # the step from lbd0 to lbd0 + dlbd0 exceeds the final load factor,
789
+ # or ends short of it by a round-off only, e.g. ten steps of 0.1
790
+ # summing to 0.9999999999999999; a step ending exactly at it is
791
+ # accepted as it is
792
+ if target is None or not lbd0 < target:
793
+ return False
794
+ lbd1 = lbd0 + dlbd0
795
+ return (lbd1 > target
796
+ or (lbd1 != target
797
+ and target - lbd1 <= FINAL_LOAD_FACTOR_RTOL*abs(target)))
730
798
 
731
799
  c = np.zeros_like(u_ref)
732
800
  lbd = 0.
@@ -1084,6 +1152,7 @@ def _solver_arc_length(an, method, silent=False):
1084
1152
  silent=silent)
1085
1153
  an.cs.append((c + dc1).copy())
1086
1154
  an.increments.append(target)
1155
+ callbacks.converged(an)
1087
1156
  if an.inertia:
1088
1157
  _converged_state(an, c + dc1, target, silent=silent)
1089
1158
  finished = True
@@ -1100,6 +1169,7 @@ def _solver_arc_length(an, method, silent=False):
1100
1169
  level=2, silent=silent)
1101
1170
  an.cs.append(c.copy()) #NOTE copy required
1102
1171
  an.increments.append(lbd)
1172
+ callbacks.converged(an)
1103
1173
  solve_kT_conv = None
1104
1174
  after_switch = switch is not None
1105
1175
  if after_switch:
@@ -1,7 +1,7 @@
1
1
  r"""Utilities for ARPACK, against the Intel MKL bug of ``dsteqr``
2
2
 
3
- With Intel MKL 2024.2.0 to 2025.0.0, :func:`scipy.sparse.linalg.eigsh`
4
- returns wrong eigenpairs, without any error, or raises ``ArpackError -8``,
3
+ When the LAPACK of SciPy is Intel MKL 2024.2.0 to 2025.0.0,
4
+ :func:`scipy.sparse.linalg.eigsh` returns wrong eigenpairs, without any error, or raises ``ArpackError -8``,
5
5
  whenever its number of Lanczos vectors is ``ncv > 32``, e.g. with SciPy's
6
6
  default ``ncv = 2 k + 1`` for ``k >= 16`` eigenpairs. MKL 2025.0.1 or newer
7
7
  is not affected, neither is :func:`scipy.sparse.linalg.eigs`.
@@ -136,6 +136,9 @@ def mkl_version():
136
136
  The build configuration of SciPy only gives the major version, e.g.
137
137
  ``'2025'``, therefore the version is read at runtime from the optional
138
138
  packages ``mkl-service`` (``mkl.get_version()``) or ``threadpoolctl``.
139
+ The MKL loaded in the process is not necessarily the LAPACK of SciPy,
140
+ e.g. ``mkl-service`` next to a SciPy linked to OpenBLAS, see
141
+ :func:`lapack_is_mkl`.
139
142
 
140
143
  Returns
141
144
  -------
@@ -463,6 +466,12 @@ def pardiso_factorization(A):
463
466
  PARDISO of the matrix scaled to a unit diagonal, with the fallback on
464
467
  perturbed pivots, see its Notes.
465
468
 
469
+ Parameters
470
+ ----------
471
+ A : array or sparse matrix
472
+ Square symmetric matrix of size ``n x n``, converted to a CSR
473
+ ``float64`` matrix.
474
+
466
475
  Returns
467
476
  -------
468
477
  factorization : callable or None
@@ -509,6 +518,15 @@ def pardiso_solve(A, refine=True):
509
518
  :func:`pardiso_factorization` is larger than ``PARDISO_ACCURACY_RTOL``,
510
519
  ``A`` is factorized by SuperLU instead, with a :class:`RuntimeWarning`.
511
520
 
521
+ Parameters
522
+ ----------
523
+ A : array or sparse matrix
524
+ Square symmetric matrix of size ``n x n``.
525
+ refine : bool, optional
526
+ Whether the solutions of PARDISO are improved by GMRES when their
527
+ relative residual is larger than ``static.PARDISO_REFINE_TOL``.
528
+ Default ``True``.
529
+
512
530
  Returns
513
531
  -------
514
532
  solve : callable
@@ -625,6 +643,11 @@ def capped_eigsh(A, k, M, sigma, which, mode='normal', tol=0,
625
643
  increasing `w` when computed in passes. ``w`` is a 1-D array of size
626
644
  ``k`` and ``x`` an array of shape ``(n, k)``.
627
645
 
646
+ Raises
647
+ ------
648
+ ValueError
649
+ When ``linear_solver`` is neither ``'splu'`` nor ``'pardiso'``.
650
+
628
651
  See Also
629
652
  --------
630
653
  arpack_max_ncv, arpack_ncv, start_kwargs, start_vector
@@ -3,8 +3,8 @@ r"""Calls to the callables of :class:`.Analysis` used by the non-linear solvers
3
3
  The callables may depend on the load factor and on the configuration
4
4
  through their optional keyword arguments, which are passed only when the
5
5
  callable declares them explicitly in its signature (a ``**kwargs`` does not
6
- count), such that the callables written for the previous versions are called
7
- exactly as before:
6
+ count), such that a callable that does not declare them is called without
7
+ them:
8
8
 
9
9
  - ``inc``: the current load factor, passed to ``calc_fint``, ``calc_kC`` and
10
10
  ``calc_kG``. It allows configuration-dependent loads, e.g. follower
@@ -81,6 +81,30 @@ solvers are scaled with the linear solution of `-\partial \boldsymbol{R}/\partia
81
81
  import inspect
82
82
 
83
83
 
84
+ def converged(an):
85
+ r"""Calls ``an.on_converged(an)``, if given, after a converged increment
86
+
87
+ Called by the non-linear solvers right after the new state is appended to
88
+ ``an.cs`` and ``an.increments``, once per converged increment, before
89
+ ``an.stop_criterion`` and before the next increment, and never for an
90
+ increment that is rejected, e.g. by the checks of the inertia or of the
91
+ branch switching, or cut.
92
+
93
+ Notes
94
+ -----
95
+ The callables of :class:`.Analysis` must be functions of the
96
+ configuration and of the load factor alone during the iterations of an
97
+ increment. A path-dependent model, e.g. a cohesive zone whose damage may
98
+ not decrease, evaluates them with its internal variables at the last
99
+ converged state, and updates these variables only with the states that
100
+ converged: ``on_converged`` is where this update belongs, with the new
101
+ state ``an.cs[-1]`` at the load factor ``an.increments[-1]``.
102
+
103
+ """
104
+ if getattr(an, 'on_converged', None) is not None:
105
+ an.on_converged(an)
106
+
107
+
84
108
  def accepts_kwarg(func, name):
85
109
  """Tell whether ``func`` declares the keyword argument ``name``
86
110
 
@@ -248,18 +248,27 @@ def crisfield_weights(K0):
248
248
  def scaled_norm(v, w):
249
249
  r"""Scaled norm `\|v\|_{\boldsymbol{d}}` of a force-like vector
250
250
 
251
+ The Euclidean norm of ``v`` with each squared entry weighted by ``w``;
252
+ the entries of null weight do not enter the norm. Used by
253
+ :func:`crisfield_zeta` and :func:`roundoff_floor`.
254
+
251
255
  Parameters
252
256
  ----------
253
257
  v : np.ndarray
254
- Force-like vector, 1-D array of size ``n``.
258
+ Force-like vector, 1-D array of size ``n``, real or complex.
255
259
  w : np.ndarray
256
260
  Weights of :func:`crisfield_weights`, 1-D array of size ``n``.
257
261
 
258
262
  Returns
259
263
  -------
260
264
  norm : float
261
- `\sqrt{\sum_j w_j v_j^2}`, of the dimension of the square root of an
262
- energy.
265
+ The scaled norm, of the dimension of the square root of an energy.
266
+
267
+ Notes
268
+ -----
269
+ `\|v\|_{\boldsymbol{d}} = \sqrt{\sum_j w_j |v_j|^2}`, with
270
+ `w_j = 1/|d_j|`, the scaled norm of Crisfield's criterion, see the module
271
+ documentation.
263
272
 
264
273
  """
265
274
  v = np.asarray(v)
@@ -269,6 +278,11 @@ def scaled_norm(v, w):
269
278
  def crisfield_zeta(R, fext, fint, w, q=None, fext_inc=None):
270
279
  r"""Relative force imbalance `\zeta` of Crisfield's criterion
271
280
 
281
+ The scaled norm of the residual ``R`` divided by the largest scaled norm
282
+ of the references ``fext``, ``fint`` and, when given, ``q`` and
283
+ ``fext_inc``, all with the weights ``w``, see :func:`scaled_norm`.
284
+ ``inf`` when the references are null and the residual is not.
285
+
272
286
  Parameters
273
287
  ----------
274
288
  R : np.ndarray
@@ -320,6 +334,10 @@ def crisfield_zeta(R, fext, fint, w, q=None, fext_inc=None):
320
334
  def roundoff_floor(Kc_abs, w=None):
321
335
  r"""Round-off floor of the residual norm
322
336
 
337
+ ``ROUNDOFF_FACTOR`` times the machine precision times the norm of
338
+ ``Kc_abs``, in the norm of the convergence criterion: the scaled norm of
339
+ :func:`scaled_norm` with the weights ``w``, or the Euclidean norm.
340
+
323
341
  Parameters
324
342
  ----------
325
343
  Kc_abs : np.ndarray
@@ -427,11 +445,9 @@ def check_convergence(an, R, fint, fext_total, fext_ref=None, q_ref=None,
427
445
 
428
446
  Notes
429
447
  -----
430
- The relative criterion is the only one of structsolve up to version
431
- 0.8.0, with the default ``relTOL=1e-6``;
432
- its reference ``fext_ref`` is useful when the load factor is close to
433
- zero, where ``fext_total`` and ``fint`` are small. When all its
434
- references are null, the relative residual is ``norm(R)`` itself.
448
+ The reference ``fext_ref`` of the relative criterion is useful when the
449
+ load factor is close to zero, where ``fext_total`` and ``fint`` are
450
+ small. When all its references are null, the relative residual is ``norm(R)`` itself.
435
451
 
436
452
  The round-off floor, see the module documentation, does not change
437
453
  ``zeta``: an iteration that it accepts may have `\zeta >` ``an.relTOL``.