Skip to content

Speed up the stability check and buckling factor - #500

Open
mitchell-tesch wants to merge 1 commit into
anastruct:masterfrom
mitchell-tesch:perf/symmetric-eigensolvers
Open

mitchell-tesch wants to merge 1 commit into
anastruct:masterfrom
mitchell-tesch:perf/symmetric-eigensolvers

Conversation

@mitchell-tesch

Copy link
Copy Markdown
Contributor

Follow-up to #490 and a comment I made there.

validate() runs on every solve(), and four times in a second-order solve. It used np.linalg.eig, which was most of the solve time on larger models. The stiffness matrix is symmetric, so there are much faster options:

  • validate() only needs to know whether all the eigenvalues are above min_eigen. That's the same as k - min_eigen * I having a Cholesky factorisation, which is much quicker to check.
  • det_linear_buckling() uses the Cholesky factor of k0 to turn the buckling problem into a symmetric one, so it can use np.linalg.eigvalsh.

If a matrix isn't symmetric, or k0 isn't positive definite, both fall back to the previous code.

One thing I noticed while testing: validate() compares against a fixed min_eigen = 1e-9. For a mechanism with very stiff members, the smallest eigenvalue comes out as rounding noise well above that, so it can be reported as stable. This already happens on master; in my tests Cholesky got about the same number of these cases wrong, just not always the same ones. A threshold relative to the stiffness would likely be the best fix, what are your thoughts?

…ng factor

SystemElements.validate() ran np.linalg.eig (eigenvalues and eigenvectors)
on the reduced stiffness matrix at every solve(); a geometrically
non-linear solve calls it four times. It only needs to know whether every
eigenvalue exceeds min_eigen. For a symmetric matrix, that holds exactly
when k - min_eigen * I is positive definite, which a Cholesky factorisation
finds about 90x faster than eig at 1200 DOFs. A non-symmetric matrix still
uses its eigenvalues.

det_linear_buckling: when k0 is symmetric positive definite (k0 = L L^T)
and kg symmetric, the eigenvalues of inv(k0) kg are those of the symmetric
L^-1 kg L^-T, found with eigvalsh; otherwise the general path as before.

Stable structures and buckling factors are unchanged. Tests are added for a
mechanism being rejected, the min_eigen threshold, and the Euler load of a
fixed-pinned member.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant