Hi,

I hope all are doing well. I want to compute eigenvalue using Scipy solver. For that, I converted the bilinear form to a sparse matrix. However, I did not get correct values compared to other eigenvalue solvers (Arnoldi) and analytical values. You can see in following attachment. The code for that is:

from ngsolve import *

import numpy as np

from ngsolve.meshes import Make1DMesh

from ngsolve.webgui import Draw

import scipy.sparse as sp

L = 10.0

thick = 0.03

width = 0.01

E = 70e3

nu = 0

N0 = 1e-3

EI = E*width*thick**3/12

GS = E/2/(1+nu)*thick*width

kappa = 5.0/6.0

mapping = lambda x : (x*L)

mesh = Make1DMesh(100, mapping=mapping, periodic=False)

fes = H1(mesh, order=2, dirichlet=“left|right”)*H1(mesh, order=2, dirichlet=“left”)
(w,beta),(dw,dbeta) = fes.TnT()
a = BilinearForm(fes, symmetric=False)
a += EI*(grad(beta)

*grad(dbeta))*((grad(w)-beta)*(grad(dw)-dbeta))*dx

*dx + kappa*GSm = BilinearForm(fes,symmetric=False)

m += N0*grad(w)*grad(dw)*dx

a.Assemble()

m.Assemble()

u = GridFunction(fes,multidim=3)

## Arnoldi method

with TaskManager():

lam = ArnoldiSolver(a.mat, m.mat, fes.FreeDofs(),list(u.vecs), shift=1)

## For sparse matrix

rows,cols,vals = a.mat.COO()

A_csr = sp.csr_matrix((vals,(rows,cols)))

rows,cols,vals = m.mat.COO()

M_csr = sp.csr_matrix((vals,(rows,cols)))

## Scipy Eigenvalue solver

Timoshenko_Beam.ipynb (4.1 KB)

n_eig = 4

from scipy.sparse.linalg import eigs

r_, w_ = eigs(A=A_csr, k=n_eig, M=M_csr, sigma=0.0)