WISDEM / RAFT

A frequency-domain dynamics model for floating wind turbines
https://openraft.readthedocs.io
Apache License 2.0
40 stars 23 forks source link

Matrix inverse #13

Closed RRiva closed 2 years ago

RRiva commented 2 years ago

Hi @gbarter, thanks for this nice code! By skimming through it I noticed that you have computed a couple of matrix inverses. Generally, this has bad numerical properties, as it's both slow and inaccurate. You should instead solve a linear system.

I suggest to:

Furthermore, if M_tot and Z are reasonably sparse, you might get an even faster solution using spsolve.

By the way, the routines from scipy.linalg might be faster than the ones from numpy on some architectures.

mattEhall commented 2 years ago

Hi @RRiva, thanks for this tip. I included your recommended switch to np.linalg.solve in this recent commit: https://github.com/WISDEM/RAFT/commit/bdc1b8b7a2f3f1754dc2e9429d6149bec8132376