Hi Guys
My code is pretty long and I am not going to show it here in it's entirety. I essentially have developed Python code which takes an excel file developed from a structural engineering package which cannot perform dynamic analysis. The excel file is read and an equivalent model developed in Python. I intend to use the Wolfram engine to calculate the eigenvalues and vectors and furthermore perform a dynamic analysis. the below is the Python code to evaluate the eigenvectors and values. It works well for small structures. I have tried a structure which has matrices that are 234x234 and the solution takes forever. Is there anyway to speed up the solution?
from wolframclient.language import wl, wlexpr
from wolframclient.evaluation import WolframLanguageSession
stiffness_matrix = K
mass_matrix = M
# Convert NumPy arrays to Mathematica strings
def numpy_to_mathematica(matrix):
return "{" + ", ".join("{" + ", ".join(map(str, row)) + "}" for row in matrix) + "}"
stiffness_matrix_str = numpy_to_mathematica(stiffness_matrix)
mass_matrix_str = numpy_to_mathematica(mass_matrix)
# Start a Wolfram Language session
session = WolframLanguageSession()
# Wolfram code to calculate eigenvalues and eigenvectors
wolfram_code = f"""
stiffnessMatrix = {stiffness_matrix_str};
massMatrix = {mass_matrix_str};
{{eigenvalues, eigenvectors}} = Eigensystem[{{stiffnessMatrix, massMatrix}}];
{{eigenvalues, eigenvectors}}
"""
# Evaluate the Wolfram code
result = session.evaluate(wlexpr(wolfram_code))
# Print the results
print("Eigenvalues:")
print(result[0])
print("\nEigenvectors:")
print(result[1])
# End the Wolfram Language session
session.terminate()