structsolve 0.9.4__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.
Files changed (63) hide show
  1. {structsolve-0.9.4/structsolve.egg-info → structsolve-0.11.0}/PKG-INFO +33 -2
  2. {structsolve-0.9.4 → structsolve-0.11.0}/README.md +30 -1
  3. {structsolve-0.9.4 → structsolve-0.11.0}/pyproject.toml +4 -1
  4. {structsolve-0.9.4 → structsolve-0.11.0}/structsolve/__init__.py +2 -0
  5. {structsolve-0.9.4 → structsolve-0.11.0}/structsolve/analysis.py +293 -47
  6. structsolve-0.11.0/structsolve/arc_length.py +1258 -0
  7. {structsolve-0.9.4 → structsolve-0.11.0}/structsolve/arpackutils.py +177 -10
  8. {structsolve-0.9.4 → structsolve-0.11.0}/structsolve/callbacks.py +2 -2
  9. {structsolve-0.9.4 → structsolve-0.11.0}/structsolve/convergence.py +24 -8
  10. structsolve-0.11.0/structsolve/displacement_control.py +32 -0
  11. {structsolve-0.9.4 → structsolve-0.11.0}/structsolve/freq.py +391 -64
  12. structsolve-0.11.0/structsolve/generalized_displacement_control.py +33 -0
  13. {structsolve-0.9.4 → structsolve-0.11.0}/structsolve/linear_buckling.py +319 -89
  14. {structsolve-0.9.4 → structsolve-0.11.0}/structsolve/newton_raphson.py +502 -24
  15. structsolve-0.11.0/structsolve/pardiso.py +353 -0
  16. {structsolve-0.9.4 → structsolve-0.11.0}/structsolve/sparseutils.py +28 -11
  17. structsolve-0.11.0/structsolve/static.py +1007 -0
  18. structsolve-0.11.0/structsolve/stopping.py +44 -0
  19. {structsolve-0.9.4 → structsolve-0.11.0/structsolve.egg-info}/PKG-INFO +33 -2
  20. {structsolve-0.9.4 → structsolve-0.11.0}/structsolve.egg-info/SOURCES.txt +20 -0
  21. {structsolve-0.9.4 → structsolve-0.11.0}/structsolve.egg-info/requires.txt +3 -0
  22. {structsolve-0.9.4 → structsolve-0.11.0}/tests/test_arc_length.py +21 -3
  23. {structsolve-0.9.4 → structsolve-0.11.0}/tests/test_arc_length_fung_kaplan.py +80 -25
  24. structsolve-0.11.0/tests/test_arc_length_robustness.py +167 -0
  25. structsolve-0.11.0/tests/test_arc_length_weights.py +87 -0
  26. {structsolve-0.9.4 → structsolve-0.11.0}/tests/test_arpackutils.py +20 -3
  27. structsolve-0.11.0/tests/test_branch_switching.py +309 -0
  28. structsolve-0.11.0/tests/test_constraint_values.py +269 -0
  29. structsolve-0.11.0/tests/test_constraint_values_load_factor.py +121 -0
  30. structsolve-0.11.0/tests/test_constraints.py +192 -0
  31. structsolve-0.11.0/tests/test_displacement_control.py +159 -0
  32. structsolve-0.11.0/tests/test_eigen_pardiso.py +228 -0
  33. structsolve-0.11.0/tests/test_factorization_cache.py +291 -0
  34. {structsolve-0.9.4 → structsolve-0.11.0}/tests/test_follower_freq_static.py +35 -2
  35. {structsolve-0.9.4 → structsolve-0.11.0}/tests/test_follower_loads.py +19 -5
  36. {structsolve-0.9.4 → structsolve-0.11.0}/tests/test_freq.py +320 -16
  37. structsolve-0.11.0/tests/test_generalized_displacement_control.py +90 -0
  38. structsolve-0.11.0/tests/test_inertia.py +401 -0
  39. structsolve-0.11.0/tests/test_inertia_unsymmetric.py +386 -0
  40. {structsolve-0.9.4 → structsolve-0.11.0}/tests/test_linear_buckling.py +89 -28
  41. {structsolve-0.9.4 → structsolve-0.11.0}/tests/test_linear_buckling_unsymmetric.py +11 -9
  42. {structsolve-0.9.4 → structsolve-0.11.0}/tests/test_load_factor_dependent_load.py +18 -7
  43. {structsolve-0.9.4 → structsolve-0.11.0}/tests/test_newton_raphson.py +24 -0
  44. structsolve-0.11.0/tests/test_pardiso.py +139 -0
  45. structsolve-0.11.0/tests/test_restart.py +95 -0
  46. {structsolve-0.9.4 → structsolve-0.11.0}/tests/test_reuse.py +2 -1
  47. structsolve-0.11.0/tests/test_simo1990_cylinder.py +176 -0
  48. {structsolve-0.9.4 → structsolve-0.11.0}/tests/test_sparse_first.py +3 -4
  49. {structsolve-0.9.4 → structsolve-0.11.0}/tests/test_static_deflection.py +16 -4
  50. structsolve-0.11.0/tests/test_stopping.py +85 -0
  51. structsolve-0.9.4/structsolve/arc_length.py +0 -475
  52. structsolve-0.9.4/structsolve/static.py +0 -147
  53. {structsolve-0.9.4 → structsolve-0.11.0}/LICENSE +0 -0
  54. {structsolve-0.9.4 → structsolve-0.11.0}/setup.cfg +0 -0
  55. {structsolve-0.9.4 → structsolve-0.11.0}/structsolve/arc_length_crisfield.py +0 -0
  56. {structsolve-0.9.4 → structsolve-0.11.0}/structsolve/arc_length_riks.py +0 -0
  57. {structsolve-0.9.4 → structsolve-0.11.0}/structsolve/logger.py +0 -0
  58. {structsolve-0.9.4 → structsolve-0.11.0}/structsolve.egg-info/dependency_links.txt +0 -0
  59. {structsolve-0.9.4 → structsolve-0.11.0}/structsolve.egg-info/top_level.txt +0 -0
  60. {structsolve-0.9.4 → structsolve-0.11.0}/tests/test_analysis.py +0 -0
  61. {structsolve-0.9.4 → structsolve-0.11.0}/tests/test_sparseutils.py +0 -0
  62. {structsolve-0.9.4 → structsolve-0.11.0}/tests/test_static.py +0 -0
  63. {structsolve-0.9.4 → 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.9.4
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
@@ -26,6 +26,8 @@ Description-Content-Type: text/markdown
26
26
  License-File: LICENSE
27
27
  Requires-Dist: numpy
28
28
  Requires-Dist: scipy
29
+ Provides-Extra: pardiso
30
+ Requires-Dist: mkl; extra == "pardiso"
29
31
  Provides-Extra: test
30
32
  Requires-Dist: pytest; extra == "test"
31
33
  Requires-Dist: pytest-cov; extra == "test"
@@ -60,10 +62,27 @@ Currently these solvers are pretty much compatible with my other repository
60
62
  [panels](https://github.com/saullocastro/panels).
61
63
 
62
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.
80
+
81
+
63
82
  Citing this library
64
83
  ===================
65
84
 
66
- Saullo G. P. Castro (2026). Structural analysis solvers tailored for semi-analytical models (Version 0.9.4). 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.11.0). Zenodo. DOI: https://doi.org/10.5281/zenodo.2581212.
67
86
 
68
87
 
69
88
  Documentation
@@ -78,6 +97,18 @@ History
78
97
 
79
98
  See [CHANGELOG.md](CHANGELOG.md) for the details of each version.
80
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
+
106
+ * version 0.10.0 (2026-11-03)
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
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`)
109
+ - Linear constraints of the solution, `C^T c = 0`, by a border of the factorizations; stop criteria and `final_load_factor`; restart of the non-linear analyses from `path_state`
110
+ - Cheaper factorizations: the linear solutions use `linear_solver`, and the null rows and columns, the symmetry check and the scaling of PARDISO cost less
111
+
81
112
  * version 0.9.4 (2026-10-28)
82
113
  - Crisfield's convergence criterion is the default of the non-linear analyses, `Analysis.convergence = 'crisfield'`, with `relTOL = 1e-9`: the residual and the reference forces are measured with the norm scaled by the diagonal of `calc_kC()` over the free degrees of freedom; the former check is kept with `convergence = 'relative'`
83
114
  - With both convergence criteria, an iteration also converges at the round-off floor of its residual, `3 eps ||(|K_C0| |c|)||`: the arc-length methods trace the snap-through of a low arch at `relTOL = 1e-9` through the null load where they stopped
@@ -25,10 +25,27 @@ Currently these solvers are pretty much compatible with my other repository
25
25
  [panels](https://github.com/saullocastro/panels).
26
26
 
27
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.
43
+
44
+
28
45
  Citing this library
29
46
  ===================
30
47
 
31
- Saullo G. P. Castro (2026). Structural analysis solvers tailored for semi-analytical models (Version 0.9.4). 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.11.0). Zenodo. DOI: https://doi.org/10.5281/zenodo.2581212.
32
49
 
33
50
 
34
51
  Documentation
@@ -43,6 +60,18 @@ History
43
60
 
44
61
  See [CHANGELOG.md](CHANGELOG.md) for the details of each version.
45
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
+
69
+ * version 0.10.0 (2026-11-03)
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
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`)
72
+ - Linear constraints of the solution, `C^T c = 0`, by a border of the factorizations; stop criteria and `final_load_factor`; restart of the non-linear analyses from `path_state`
73
+ - Cheaper factorizations: the linear solutions use `linear_solver`, and the null rows and columns, the symmetry check and the scaling of PARDISO cost less
74
+
46
75
  * version 0.9.4 (2026-10-28)
47
76
  - Crisfield's convergence criterion is the default of the non-linear analyses, `Analysis.convergence = 'crisfield'`, with `relTOL = 1e-9`: the residual and the reference forces are measured with the norm scaled by the diagonal of `calc_kC()` over the free degrees of freedom; the former check is kept with `convergence = 'relative'`
48
77
  - With both convergence criteria, an iteration also converges at the round-off floor of its residual, `3 eps ||(|K_C0| |c|)||`: the arc-length methods trace the snap-through of a low arch at `relTOL = 1e-9` through the null load where they stopped
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "structsolve"
7
- version = "0.9.4"
7
+ version = "0.11.0"
8
8
  description = "Structural analysis solvers"
9
9
  readme = "README.md"
10
10
  license = "BSD-3-Clause"
@@ -38,6 +38,9 @@ dependencies = [
38
38
  ]
39
39
 
40
40
  [project.optional-dependencies]
41
+ pardiso = [
42
+ "mkl",
43
+ ]
41
44
  test = [
42
45
  "pytest",
43
46
  "pytest-cov",
@@ -17,6 +17,8 @@ directly from the ``structsolve`` namespace:
17
17
  - :class:`.DenseFallbackWarning`: warning of :func:`.lb` and :func:`.freq`
18
18
  when a dense solver was used as a last resort
19
19
 
20
+ and the criteria to stop a non-linear analysis in :mod:`structsolve.stopping`.
21
+
20
22
  """
21
23
  from __future__ import absolute_import
22
24
 
@@ -12,13 +12,18 @@ from __future__ import absolute_import
12
12
 
13
13
  import numpy as np
14
14
 
15
- from .static import solve, _factorize
15
+ from .static import solve, _factorize, _FactorizationCache
16
16
  from .logger import msg, warn
17
17
  from . import callbacks
18
- from .newton_raphson import _check_convergence, _weights, _abs_matrix
18
+ from .newton_raphson import (_check_convergence, _weights, _abs_matrix,
19
+ _constraint_matrix, _constraint_values,
20
+ _residual_projector)
19
21
  from .newton_raphson import _solver_NR
20
22
  from .arc_length_riks import _solver_arc_length_riks
21
23
  from .arc_length_crisfield import _solver_arc_length_crisfield
24
+ from .displacement_control import _solver_displacement_control
25
+ from .generalized_displacement_control import (
26
+ _solver_generalized_displacement_control)
22
27
 
23
28
 
24
29
  class Analysis(object):
@@ -38,37 +43,158 @@ class Analysis(object):
38
43
  The analysis parameters are attributes of this class, described in the
39
44
  following tables together with their default values:
40
45
 
41
- ======================== ==================================================
42
- Non-Linear Algorithm Description
43
- ======================== ==================================================
44
- ``NL_method`` ``str``, ``'NR'`` (default) for the
45
- Newton-Raphson method, see
46
- :func:`.newton_raphson._solver_NR`, or
47
- ``'arc_length_riks'`` and
48
- ``'arc_length_crisfield'`` for the arc-length
49
- methods, see
50
- :func:`.arc_length._solver_arc_length`
51
- ``line_search`` ``bool``, activates a safeguarding line-search,
52
- for the Newton-Raphson method only, see
53
- :func:`.newton_raphson._NR_iterations`. Default
54
- is ``False``
55
- ``max_iter_line_search`` ``int``, maximum number of iterations of the
56
- line-search. Default is ``20``
57
- ``modified_NR`` ``bool``, activates the modified Newton-Raphson
58
- method, where the tangent stiffness matrix is
59
- not updated at every iteration. Default is
60
- ``False``, i.e. full Newton-Raphson
61
- ``compute_every_n`` ``int``, if ``modified_NR=True``, the tangent
62
- stiffness matrix is updated at every `n`
63
- iterations. Default is ``6``
64
- ``kT_initial_state`` ``bool``, if ``modified_NR=True``, tells if the
65
- tangent stiffness matrix should be calculated
66
- already at the first iteration of the analysis,
67
- which is required for example when initial
68
- imperfections take place. Otherwise the linear
69
- constitutive stiffness matrix is used. Default
70
- is ``True``
71
- ======================== ==================================================
46
+ ============================ =============================================
47
+ Non-Linear Algorithm Description
48
+ ============================ =============================================
49
+ ``NL_method`` ``str``, ``'NR'`` (default) for the
50
+ Newton-Raphson method, see
51
+ :func:`.newton_raphson._solver_NR`, or
52
+ ``'arc_length_riks'`` and
53
+ ``'arc_length_crisfield'`` for the arc-length
54
+ methods, or ``'displacement_control'`` for
55
+ the indirect displacement control, or
56
+ ``'generalized_displacement_control'``,
57
+ see
58
+ :func:`.arc_length._solver_arc_length`
59
+ ``control_vector`` ``array``, the vector
60
+ `\boldsymbol{\psi}` of the controlled
61
+ quantity `\boldsymbol{\psi}^\top
62
+ \boldsymbol{c}` of
63
+ ``NL_method='displacement_control'``, e.g.
64
+ a unit vector that picks one degree of
65
+ freedom, or a buckling mode. Default is
66
+ ``None``
67
+ ``control_scale`` ``float``, the reference value of the
68
+ controlled quantity, which makes the step
69
+ dimensionless. Default is ``None``, i.e.
70
+ `|\boldsymbol{\psi}^\top
71
+ \boldsymbol{u}_{ref}|`, its value in the linear solution for a
72
+ load factor of 1
73
+ ``line_search`` ``bool``, activates a safeguarding
74
+ line-search, for the Newton-Raphson method
75
+ only, see
76
+ :func:`.newton_raphson._NR_iterations`.
77
+ Default is ``False``
78
+ ``max_iter_line_search`` ``int``, maximum number of iterations of the
79
+ line-search. Default is ``20``
80
+ ``arc_length_line_search`` ``bool``, activates a backtracking line
81
+ search on the corrections of the arc-length
82
+ methods, see
83
+ :func:`.arc_length._solver_arc_length`.
84
+ Default is ``False``
85
+ ``branch_switching`` ``int``, number of bifurcation points at
86
+ which the arc-length and the displacement
87
+ control methods switch to the bifurcated
88
+ branch, along the critical eigenvector,
89
+ where the number of negative eigenvalues
90
+ increases or decreases, which requires
91
+ ``inertia``, see
92
+ :func:`.arc_length._solver_arc_length`.
93
+ Default is ``0``
94
+ ``arc_length_weights`` ``array``, non-negative weights of the
95
+ degrees of freedom in the norm of the
96
+ arc-length constraint, e.g. 1 for the
97
+ translations and 0 for their derivatives
98
+ or the rotations, see
99
+ :func:`.arc_length._solver_arc_length`.
100
+ Default is ``None``, all equal to 1
101
+ ``early_divergence`` ``bool``, stops a diverging step earlier,
102
+ such that its increment is cut before the
103
+ iterations are spent, see
104
+ :func:`.newton_raphson._check_divergence`.
105
+ Default is ``False``
106
+ ``modified_NR`` ``bool``, activates the modified
107
+ Newton-Raphson method, where the tangent
108
+ stiffness matrix is not updated at every
109
+ iteration. Default is ``False``, i.e. full
110
+ Newton-Raphson
111
+ ``compute_every_n`` ``int``, if ``modified_NR=True``, the tangent
112
+ stiffness matrix is updated at every `n`
113
+ iterations. Default is ``6``
114
+ ``kT_initial_state`` ``bool``, if ``modified_NR=True``, tells if
115
+ the tangent stiffness matrix should be
116
+ calculated already at the first iteration of
117
+ the analysis, which is required for example
118
+ when initial imperfections take place.
119
+ Otherwise the linear constitutive stiffness
120
+ matrix is used. Default is ``True``
121
+ ``linear_solver`` ``str``, factorization of the tangent
122
+ stiffness matrix of the non-linear solvers,
123
+ ``'splu'`` (default), the sparse LU of
124
+ SuperLU, or ``'pardiso'``, the symmetric
125
+ indefinite factorization of PARDISO, which
126
+ requires oneMKL, see :mod:`.pardiso`, and
127
+ gives the number
128
+ of negative eigenvalues, see
129
+ :func:`.static._factorize`
130
+ ``inertia`` ``bool``, the tangent stiffness matrix is
131
+ factorized at every converged increment of
132
+ the non-linear analyses, and its number of
133
+ negative eigenvalues (``'pardiso'``) and the
134
+ sign of its determinant are recorded, such
135
+ that limit points, bifurcations crossed and
136
+ unstable branches are visible. Default is
137
+ ``False``
138
+ ``inertia_num_eigvals`` ``int`` `k`, with ``inertia``: when the
139
+ count of PARDISO is not available, e.g.
140
+ for an unsymmetric tangent stiffness
141
+ matrix, the number of its negative real
142
+ eigenvalues among the `k` of smallest
143
+ magnitude, scaled by the diagonal of the
144
+ linear stiffness matrix, by shift-invert
145
+ with ARPACK and the LU factorization of
146
+ the converged state, see
147
+ :func:`.newton_raphson._eigvals_inertia`.
148
+ Default is ``None``, not computed
149
+ ``max_inertia_jump`` ``int``, a converged increment whose number
150
+ of negative eigenvalues changed by more
151
+ than this value is repeated with a smaller
152
+ increment, which requires ``inertia`` and
153
+ ``linear_solver='pardiso'`` or
154
+ ``inertia_num_eigvals``. Default is
155
+ ``None``
156
+ ``constraints`` ``array`` or sparse matrix `\boldsymbol{C}`,
157
+ of shape ``(n, m)``, a 1-D array for one
158
+ constraint: the linear constraints
159
+ `\boldsymbol{C}^\top \boldsymbol{c} =
160
+ \boldsymbol{0}` of the solution, e.g. an
161
+ inertia relief or multipoint constraints,
162
+ imposed by bordering every factorization
163
+ of the stiffness matrices, see
164
+ :func:`.static._factorize`, in the linear
165
+ and the non-linear analyses. Default is
166
+ ``None``
167
+ ``constraint_values`` ``array`` `\boldsymbol{d}`, of shape
168
+ ``(m,)``, the values of the constraints,
169
+ `\boldsymbol{C}^\top \boldsymbol{c} =
170
+ \lambda \boldsymbol{d}` along the
171
+ non-linear path and `\boldsymbol{C}^\top
172
+ \boldsymbol{c} = \boldsymbol{d}` in the
173
+ linear analysis, e.g. a displacement or a
174
+ rotation prescribed in proportion to the
175
+ load factor, with or without external
176
+ load, which requires ``constraints``.
177
+ Default is ``None``, all null
178
+ ``stop_criterion`` ``callable``, ``stop_criterion(an)`` is
179
+ called after every converged increment of
180
+ the non-linear analyses, which stop when it
181
+ returns ``True``, e.g. a number of
182
+ increments beyond the first limit point or
183
+ a displacement measure, see
184
+ :mod:`.stopping`. Default is ``None``
185
+ ``final_load_factor`` ``float``, the load factor at which the
186
+ non-linear analyses finish, exactly, or,
187
+ for the arc-length and displacement control
188
+ methods, ``None``: the path is traced
189
+ beyond any load factor until another stop,
190
+ e.g. ``stop_criterion`` or
191
+ ``maxArcLength``. Default is ``1.``
192
+ ``restart_state`` ``dict``, the ``path_state`` of a previous
193
+ analysis with the same ``NL_method``, from
194
+ whose last converged increment the
195
+ non-linear analysis continues. Default is
196
+ ``None``
197
+ ============================ =============================================
72
198
 
73
199
  ================ =================================================
74
200
  Incrementation Description
@@ -107,9 +233,7 @@ class Analysis(object):
107
233
  and internal force vectors. Not used if
108
234
  ``None``. Default is ``1.e-9``, the tight
109
235
  tolerance of Crisfield's criterion with a
110
- consistent tangent; until version 0.8.0 the
111
- relative criterion was the only one, with the
112
- default ``1.e-6``
236
+ consistent tangent
113
237
  ``absTOL`` the convergence is also achieved when the
114
238
  maximum absolute residual force is smaller
115
239
  than this value, which depends on the units of
@@ -166,6 +290,33 @@ class Analysis(object):
166
290
  cs : list
167
291
  Solution vectors of the converged increments, filled by
168
292
  :meth:`.static`.
293
+ num_negative_eigvals : list
294
+ With ``inertia=True``, for each converged increment of a non-linear
295
+ analysis, the number of negative eigenvalues of the tangent
296
+ stiffness matrix on the degrees of freedom whose row or column is
297
+ not null, ``None`` with ``linear_solver='splu'``, when PARDISO fell
298
+ back to SuperLU for an unsymmetric matrix, or for a singular matrix,
299
+ unless ``inertia_num_eigvals`` is given: the number of negative real
300
+ eigenvalues among the ``inertia_num_eigvals`` of smallest magnitude
301
+ is then recorded for the SuperLU factorizations. Empty otherwise.
302
+ det_signs : list
303
+ With ``inertia=True``, for each converged increment of a non-linear
304
+ analysis, the sign of the determinant of the same matrix, ``1`` or
305
+ ``-1``, ``0`` when it is singular. Empty otherwise.
306
+ num_perturbed_pivots : list
307
+ With ``inertia=True`` and ``linear_solver='pardiso'``, the number of
308
+ pivots perturbed by PARDISO at each converged increment, which makes
309
+ the count of negative eigenvalues uncertain when not zero; ``None``
310
+ otherwise.
311
+ branch_points : list
312
+ With ``branch_switching``, the indices in ``increments`` of the
313
+ converged increments from which the path was switched to a
314
+ bifurcated branch.
315
+ path_state : dict or None
316
+ After each converged increment of a non-linear analysis, the state
317
+ from which it can be continued, see ``restart_state``: the solution,
318
+ the load factor, the next increment and the directions of the
319
+ predictors.
169
320
  last_analysis : str
170
321
  Type of the last analysis run, ``'static'`` after :meth:`.static`.
171
322
 
@@ -227,14 +378,38 @@ class Analysis(object):
227
378
  The tangent stiffness matrix may then be unsymmetric, which the solvers
228
379
  support, since they use LU factorizations.
229
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
+
230
396
  """
231
397
  __slots__ = ['NL_method', 'line_search', 'max_iter_line_search',
398
+ 'arc_length_line_search',
399
+ 'early_divergence', 'arc_length_weights', 'control_vector',
400
+ 'control_scale', 'linear_solver', 'inertia',
401
+ 'constraints', 'constraint_values', 'stop_criterion',
402
+ 'final_load_factor',
403
+ 'branch_switching', 'max_inertia_jump', 'inertia_num_eigvals',
404
+ 'restart_state', 'path_state', 'branch_points',
405
+ 'num_negative_eigvals', 'det_signs', 'num_perturbed_pivots',
232
406
  'modified_NR', 'compute_every_n',
233
407
  'kT_initial_state', 'initialInc', 'minInc', 'maxInc',
234
408
  'maxArcLength', 'convergence', 'absTOL', 'relTOL', 'maxNumIter',
235
409
  'too_slow_TOL',
236
410
  'increments', 'cs', 'last_analysis', 'calc_fext', 'calc_kC',
237
- 'calc_fint', 'calc_kG']
411
+ 'calc_fint', 'calc_kG', '_factorization_cache',
412
+ '_inertia_scaling']
238
413
 
239
414
 
240
415
  def __init__(self, calc_fext=None, calc_fint=None, calc_kC=None,
@@ -243,6 +418,21 @@ class Analysis(object):
243
418
  self.NL_method = 'NR'
244
419
  self.line_search = False
245
420
  self.max_iter_line_search = 20
421
+ self.arc_length_line_search = False
422
+ self.early_divergence = False
423
+ self.arc_length_weights = None
424
+ self.control_vector = None
425
+ self.control_scale = None
426
+ self.linear_solver = 'splu'
427
+ self.inertia = False
428
+ self.constraints = None
429
+ self.constraint_values = None
430
+ self.stop_criterion = None
431
+ self.final_load_factor = 1.
432
+ self.branch_switching = 0
433
+ self.max_inertia_jump = None
434
+ self.inertia_num_eigvals = None
435
+ self.restart_state = None
246
436
  self.modified_NR = False
247
437
  self.compute_every_n = 6
248
438
  self.kT_initial_state = True
@@ -267,9 +457,18 @@ class Analysis(object):
267
457
  # outputs to be filled
268
458
  self.increments = None
269
459
  self.cs = None
460
+ self.num_negative_eigvals = None
461
+ self.det_signs = None
462
+ self.num_perturbed_pivots = None
463
+ self.branch_points = None
464
+ self.path_state = None
270
465
 
271
466
  # flag telling the last analysis
272
467
  self.last_analysis = ''
468
+ # pattern-dependent work of the factorizations of a running analysis
469
+ self._factorization_cache = None
470
+ # scaling of the counts of inertia_num_eigvals of a running analysis
471
+ self._inertia_scaling = None
273
472
 
274
473
 
275
474
  def static(self, NLgeom=False, silent=False):
@@ -310,7 +509,9 @@ class Analysis(object):
310
509
  ------
311
510
  ValueError
312
511
  When ``NLgeom=True`` and the ``NL_method`` attribute is not
313
- ``'NR'``, ``'arc_length_riks'`` or ``'arc_length_crisfield'``.
512
+ ``'NR'``, ``'arc_length_riks'``, ``'arc_length_crisfield'``,
513
+ ``'displacement_control'`` or
514
+ ``'generalized_displacement_control'``.
314
515
 
315
516
  Notes
316
517
  -----
@@ -339,28 +540,69 @@ class Analysis(object):
339
540
  multipliers `\lambda` of `(\boldsymbol{K}_C + \lambda \boldsymbol{K}_f) \boldsymbol{u} = \boldsymbol{0}`,
340
541
  including the negative and complex ones.
341
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
+
342
563
  """
343
564
  self.increments = []
344
565
  self.cs = []
566
+ self.num_negative_eigvals = []
567
+ self.det_signs = []
568
+ self.num_perturbed_pivots = []
569
+ self.branch_points = []
570
+ self.path_state = None
345
571
 
346
572
  if NLgeom:
347
573
  self.maxInc = max(self.initialInc, self.maxInc)
348
574
  msg('Started Non-Linear Static Analysis', silent=silent)
349
- if self.NL_method == 'NR':
350
- _solver_NR(self, silent=silent)
351
- elif self.NL_method == 'arc_length_riks':
352
- _solver_arc_length_riks(self, silent=silent)
353
- elif self.NL_method == 'arc_length_crisfield':
354
- _solver_arc_length_crisfield(self, silent=silent)
355
- else:
575
+ solvers = {
576
+ 'NR': _solver_NR,
577
+ 'arc_length_riks': _solver_arc_length_riks,
578
+ 'arc_length_crisfield': _solver_arc_length_crisfield,
579
+ 'displacement_control': _solver_displacement_control,
580
+ 'generalized_displacement_control':
581
+ _solver_generalized_displacement_control}
582
+ if self.NL_method not in solvers:
356
583
  raise ValueError('{0} is an invalid NL_method'.format(self.NL_method))
584
+ # the work of the factorizations that depends only on the
585
+ # pattern of the tangent stiffness matrix is reused
586
+ self._factorization_cache = _FactorizationCache()
587
+ self._inertia_scaling = None
588
+ try:
589
+ solvers[self.NL_method](self, silent=silent)
590
+ finally:
591
+ self._factorization_cache.close()
592
+ self._factorization_cache = None
593
+ self._inertia_scaling = None
357
594
 
358
595
  else:
359
596
  msg('Started Linear Static Analysis', silent=silent)
360
597
  fext = self.calc_fext(silent=silent)
361
598
  k0 = self.calc_kC(silent=silent)
362
599
 
363
- c = solve(k0, fext, silent=silent)
600
+ d = _constraint_values(self)
601
+ if self.constraints is None:
602
+ c = solve(k0, fext, silent=silent)
603
+ else:
604
+ c = _factorize(k0, constraints=_constraint_matrix(self))(fext,
605
+ d)
364
606
  if callbacks.is_load_configuration_dependent(self):
365
607
  c = self._linear_static_follower(k0, c, silent)
366
608
 
@@ -380,12 +622,15 @@ class Analysis(object):
380
622
  level=2, silent=silent)
381
623
  w = _weights(self, k0)
382
624
  k0_abs = _abs_matrix(k0)
625
+ proj = _residual_projector(self, w)
383
626
  # k0 is factorized once for all the corrections
384
627
  solve_k0 = None
385
628
  for iteration in range(1, self.maxNumIter + 1):
386
629
  fext = self.calc_fext(inc=1., c=c, silent=True)
387
630
  fint = k0 @ c
388
631
  R = fint - fext
632
+ if proj is not None:
633
+ R = proj(R)
389
634
  conv, Rnorm, Rrel, roundoff = _check_convergence(self, R, fint,
390
635
  fext, w=w, Kc_abs=k0_abs @ np.abs(c), full_output=True)
391
636
  msg('Iteration: %d, %s = %1.3e%s' % (iteration, 'zeta' if
@@ -398,7 +643,8 @@ class Analysis(object):
398
643
  break
399
644
  if solve_k0 is None:
400
645
  try:
401
- solve_k0 = _factorize(k0)
646
+ solve_k0 = _factorize(k0,
647
+ constraints=_constraint_matrix(self))
402
648
  except RuntimeError:
403
649
  break
404
650
  c = c + solve_k0(-R)