Skip to content

Anisotropic FEM forces float32 matrices #104

@VictorBarnes

Description

@VictorBarnes

Question/Support Request

Hi LaPy developers,

I noticed the Solver class uses different default dtypes depending on whether the isotropic or anisotropic FEM method is used.

In Solver._fem_tria, the stiffness and mass matrices are each cast to a csc_matrix without an explicit dtype (taking the default float64). However, in Solver._fem_tria_aniso, the stiffness and mass matrices are each cast to a csc_matrix with dtype=np.float32. This means using the aniso method reduces the precision of the LBO matrices and the resulting eigenmodes and eigenvectors of the generalised eigenvalue problem also come out as float32.

This has become a problem because I have been performing large operations on the eigenvectors of a high resolution mesh and the float32 eigenvectors sometimes trigger matmul precision warnings. I'm also seeing NaNs appear in some of the outputs of these computations. However, these issues don't occur when using float64 eigenvectors.

Was there a reason for why the mass and stiffness matrices of the anisotropic LBO were cast to float32? If it is not essential to reduce the precision would you be able to remove the explicit dtype casting in _fem_tria_aniso? If it is essential, would you be able to add a dtype parameter to the Solver so the user can specify the precision they want?

Thanks in advance.

Environment

  • LaPy Version: 1.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomersquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions