structsolve 0.10.0__tar.gz → 0.11.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.
- {structsolve-0.10.0/structsolve.egg-info → structsolve-0.11.0}/PKG-INFO +24 -4
- {structsolve-0.10.0 → structsolve-0.11.0}/README.md +23 -3
- {structsolve-0.10.0 → structsolve-0.11.0}/pyproject.toml +1 -1
- {structsolve-0.10.0 → structsolve-0.11.0}/structsolve/analysis.py +36 -3
- {structsolve-0.10.0 → structsolve-0.11.0}/structsolve/arc_length.py +111 -43
- {structsolve-0.10.0 → structsolve-0.11.0}/structsolve/arpackutils.py +25 -2
- {structsolve-0.10.0 → structsolve-0.11.0}/structsolve/callbacks.py +2 -2
- {structsolve-0.10.0 → structsolve-0.11.0}/structsolve/convergence.py +24 -8
- {structsolve-0.10.0 → structsolve-0.11.0}/structsolve/freq.py +349 -54
- {structsolve-0.10.0 → structsolve-0.11.0}/structsolve/linear_buckling.py +175 -60
- {structsolve-0.10.0 → structsolve-0.11.0}/structsolve/newton_raphson.py +49 -25
- {structsolve-0.10.0 → structsolve-0.11.0}/structsolve/pardiso.py +124 -7
- {structsolve-0.10.0 → structsolve-0.11.0}/structsolve/sparseutils.py +3 -2
- {structsolve-0.10.0 → structsolve-0.11.0}/structsolve/static.py +49 -12
- {structsolve-0.10.0 → structsolve-0.11.0}/structsolve/stopping.py +3 -0
- {structsolve-0.10.0 → structsolve-0.11.0/structsolve.egg-info}/PKG-INFO +24 -4
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_arc_length.py +21 -3
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_arc_length_fung_kaplan.py +80 -25
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_arc_length_robustness.py +2 -2
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_arpackutils.py +20 -3
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_branch_switching.py +7 -3
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_follower_freq_static.py +17 -2
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_follower_loads.py +19 -5
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_freq.py +320 -16
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_inertia_unsymmetric.py +12 -6
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_linear_buckling.py +87 -27
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_linear_buckling_unsymmetric.py +11 -9
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_load_factor_dependent_load.py +18 -7
- structsolve-0.11.0/tests/test_simo1990_cylinder.py +176 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_sparse_first.py +2 -3
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_static_deflection.py +16 -4
- structsolve-0.10.0/tests/test_simo1990_cylinder.py +0 -124
- {structsolve-0.10.0 → structsolve-0.11.0}/LICENSE +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/setup.cfg +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/structsolve/__init__.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/structsolve/arc_length_crisfield.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/structsolve/arc_length_riks.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/structsolve/displacement_control.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/structsolve/generalized_displacement_control.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/structsolve/logger.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/structsolve.egg-info/SOURCES.txt +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/structsolve.egg-info/dependency_links.txt +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/structsolve.egg-info/requires.txt +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/structsolve.egg-info/top_level.txt +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_analysis.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_arc_length_weights.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_constraint_values.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_constraint_values_load_factor.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_constraints.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_displacement_control.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_eigen_pardiso.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_factorization_cache.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_generalized_displacement_control.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_inertia.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_newton_raphson.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_pardiso.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_restart.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_reuse.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_sparseutils.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_static.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.0}/tests/test_stopping.py +0 -0
- {structsolve-0.10.0 → structsolve-0.11.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.
|
|
3
|
+
Version: 0.11.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
|
-
|
|
65
|
-
|
|
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.
|
|
85
|
+
Saullo G. P. Castro (2026). Structural analysis solvers tailored for semi-analytical models (Version 0.11.0). Zenodo. DOI: https://doi.org/10.5281/zenodo.2581212.
|
|
72
86
|
|
|
73
87
|
|
|
74
88
|
Documentation
|
|
@@ -83,6 +97,12 @@ History
|
|
|
83
97
|
|
|
84
98
|
See [CHANGELOG.md](CHANGELOG.md) for the details of each version.
|
|
85
99
|
|
|
100
|
+
* version 0.11.0 (2026-11-13)
|
|
101
|
+
- `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
|
|
102
|
+
- `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
|
|
103
|
+
- 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
|
|
104
|
+
- 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`
|
|
105
|
+
|
|
86
106
|
* version 0.10.0 (2026-11-03)
|
|
87
107
|
- 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
108
|
- 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
|
-
|
|
28
|
-
|
|
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.
|
|
48
|
+
Saullo G. P. Castro (2026). Structural analysis solvers tailored for semi-analytical models (Version 0.11.0). Zenodo. DOI: https://doi.org/10.5281/zenodo.2581212.
|
|
35
49
|
|
|
36
50
|
|
|
37
51
|
Documentation
|
|
@@ -46,6 +60,12 @@ History
|
|
|
46
60
|
|
|
47
61
|
See [CHANGELOG.md](CHANGELOG.md) for the details of each version.
|
|
48
62
|
|
|
63
|
+
* version 0.11.0 (2026-11-13)
|
|
64
|
+
- `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
|
|
65
|
+
- `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
|
|
66
|
+
- 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
|
|
67
|
+
- 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`
|
|
68
|
+
|
|
49
69
|
* version 0.10.0 (2026-11-03)
|
|
50
70
|
- 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
71
|
- 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`)
|
|
@@ -233,9 +233,7 @@ class Analysis(object):
|
|
|
233
233
|
and internal force vectors. Not used if
|
|
234
234
|
``None``. Default is ``1.e-9``, the tight
|
|
235
235
|
tolerance of Crisfield's criterion with a
|
|
236
|
-
consistent tangent
|
|
237
|
-
relative criterion was the only one, with the
|
|
238
|
-
default ``1.e-6``
|
|
236
|
+
consistent tangent
|
|
239
237
|
``absTOL`` the convergence is also achieved when the
|
|
240
238
|
maximum absolute residual force is smaller
|
|
241
239
|
than this value, which depends on the units of
|
|
@@ -380,6 +378,21 @@ class Analysis(object):
|
|
|
380
378
|
The tangent stiffness matrix may then be unsymmetric, which the solvers
|
|
381
379
|
support, since they use LU factorizations.
|
|
382
380
|
|
|
381
|
+
Examples
|
|
382
|
+
--------
|
|
383
|
+
Linear static analysis of two uncoupled springs:
|
|
384
|
+
|
|
385
|
+
>>> import numpy as np
|
|
386
|
+
>>> from scipy.sparse import diags
|
|
387
|
+
>>> from structsolve import Analysis
|
|
388
|
+
>>> an = Analysis(
|
|
389
|
+
... calc_fext=lambda inc=1., silent=False: np.array([2., 2.]),
|
|
390
|
+
... calc_kC=lambda c=None, NLgeom=False, silent=False:
|
|
391
|
+
... diags([2., 4.]).tocsr())
|
|
392
|
+
>>> increments, cs = an.static(silent=True)
|
|
393
|
+
>>> increments, cs[0]
|
|
394
|
+
([1.0], array([1. , 0.5]))
|
|
395
|
+
|
|
383
396
|
"""
|
|
384
397
|
__slots__ = ['NL_method', 'line_search', 'max_iter_line_search',
|
|
385
398
|
'arc_length_line_search',
|
|
@@ -527,6 +540,26 @@ class Analysis(object):
|
|
|
527
540
|
multipliers `\lambda` of `(\boldsymbol{K}_C + \lambda \boldsymbol{K}_f) \boldsymbol{u} = \boldsymbol{0}`,
|
|
528
541
|
including the negative and complex ones.
|
|
529
542
|
|
|
543
|
+
Examples
|
|
544
|
+
--------
|
|
545
|
+
Non-linear analysis of two hardening springs,
|
|
546
|
+
``fint = k*c + c**3``, with the Newton-Raphson solver:
|
|
547
|
+
|
|
548
|
+
>>> import numpy as np
|
|
549
|
+
>>> from scipy.sparse import diags
|
|
550
|
+
>>> from structsolve import Analysis
|
|
551
|
+
>>> k = np.array([1., 2.])
|
|
552
|
+
>>> an = Analysis(
|
|
553
|
+
... calc_fext=lambda inc=1., silent=False: np.array([2., 3.]),
|
|
554
|
+
... calc_fint=lambda c, silent=False: k*c + c**3,
|
|
555
|
+
... calc_kC=lambda c=None, NLgeom=False, silent=False:
|
|
556
|
+
... diags(k + 3*c**2 if NLgeom else k).tocsr(),
|
|
557
|
+
... calc_kG=lambda c=None, NLgeom=False, silent=False:
|
|
558
|
+
... diags([0., 0.]).tocsr())
|
|
559
|
+
>>> increments, cs = an.static(NLgeom=True, silent=True)
|
|
560
|
+
>>> increments[-1], cs[-1].round(6)
|
|
561
|
+
(1.0, array([1., 1.]))
|
|
562
|
+
|
|
530
563
|
"""
|
|
531
564
|
self.increments = []
|
|
532
565
|
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
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
``
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
|
195
|
-
``
|
|
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
|
-
|
|
729
|
-
|
|
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.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
r"""Utilities for ARPACK, against the Intel MKL bug of ``dsteqr``
|
|
2
2
|
|
|
3
|
-
|
|
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
|
|
7
|
-
|
|
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
|
|
@@ -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
|
-
|
|
262
|
-
|
|
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
|
|
431
|
-
|
|
432
|
-
|
|
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``.
|