Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove scipy dependency by replacing eigvals() function #138

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions anastruct/fem/system_components/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from typing import TYPE_CHECKING, Optional

import numpy as np
from scipy import linalg # type: ignore

from anastruct.basic import converge

if TYPE_CHECKING:
Expand Down Expand Up @@ -112,7 +110,11 @@ def det_linear_buckling(system: "SystemElements") -> float:
kg = system.reduced_system_matrix - k0
# solve (k -λkg)x = 0

eigenvalues = np.abs(linalg.eigvals(k0, kg))
# The following two lines are equivalent to the cleaner
# scipy.linalg.eigvals(k0, kg), but doing this allows us
# to drop the scipy dependency
invkg_k0 = np.linalg.inv(kg) * k0
eigenvalues = np.abs(np.linalg.eigvals(invkg_k0))
return float(np.min(eigenvalues))


Expand Down
Loading