slepc.EPS() not found

Hello all.
Fenicsx finds the slepc module at import time, but when
eigs = slepc.EPS().create(mesh.comm)
is encountered, the program crashes with the following error:

Traceback (most recent call last):
  File "/home/bill/Cluster/Fenics2020/Helix/HelicalSection2.py", line 127, in <module>
    eigs = slepc.EPS().create(mesh.comm)
AttributeError: module 'slepc4py' has no attribute 'EPS'

This is the code I used.

# Generate unit cell of helical structure (no periodic boundary in this case).
import sys
import numpy as np
from mpi4py import MPI as nMPI
from petsc4py import PETSc
import slepc4py as slepc
import meshio
import ufl
from dolfinx.mesh import locate_entities_boundary, meshtags
from dolfinx.io import gmshio
from dolfinx import fem
from dolfinx import io
import gmsh

l = 6.0 # Cell length
r = 6.0 # Cell radius
rh = 2.0 # Helix radius
rw = 0.2 # wire radius
npts = 100 # number of points of spline curve
eps = 1.0e-5

Gamma = 0 + 6.283j

comm = nMPI.COMM_WORLD
mpiRank = comm.rank
modelRank = 0 # process where GMSG runs

if mpiRank == modelRank:

    gmsh.initialize()
    gmsh.option.setNumber('General.Terminal', 1)
    gmsh.model.add("Helix Cell")

    c = gmsh.model.occ.addCylinder(0, 0, 0, 0, 0, l, r, 1, 2*np.pi)

    dt = 2 * np.pi / npts
    p = []
    for n in range(npts+3):
        theta = 2 * np.pi * (n-1) / npts
        kk = gmsh.model.occ.addCircle(rh * np.cos(theta), rh * np.sin(theta), (n -1) * l / npts, rw)
        p.append(gmsh.model.occ.addCurveLoop([kk], tag=-1))
    print(p)
    s = gmsh.model.occ.addThruSections(p, tag=-1)
    print(s)
    v = gmsh.model.occ.cut([(3,c)], s, tag=100, removeObject=True, removeTool=True)
    print("v={}".format(v))
    for n in range(npts+3):
        gmsh.model.occ.remove([(1,p[n])], recursive=True)

    gmsh.model.occ.synchronize()

    bb = gmsh.model.getEntities(dim=3)
    pt = gmsh.model.getBoundary(bb, combined=True, oriented=False, recursive=False)
    print(pt)
# Boundary conditions
    Bot = []
    Top = []
    PEC = []
    for bb in pt:
        CoM = gmsh.model.occ.getCenterOfMass(bb[0], bb[1])
        print(CoM)
        if(np.abs(CoM[2]) < eps):
            Bot.append(bb[1])
        elif(np.abs(CoM[2]-l) < eps):
            Top.append(bb[1])
        else:
            PEC.append(bb[1])

    print(Bot, Top, PEC)
    gmsh.model.mesh.setPeriodic(2, Top, Bot, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, l, 0, 0, 0, 1])

    gmsh.model.addPhysicalGroup(3, [100], 1) # Helix volume
    gmsh.model.setPhysicalName(3, 1, "HelixVolume")
    gmsh.model.addPhysicalGroup(2, Top, 1) # Top BC (slave periodic BC)
    gmsh.model.addPhysicalGroup(2, Bot, 2) # Bottom BC (master periodic BC)
    gmsh.model.addPhysicalGroup(2, PEC, 3) # PEC boundary
    gmsh.model.setPhysicalName(2, 1, "TopPBC")
    gmsh.model.setPhysicalName(2, 2, "BotPBC")
    gmsh.model.setPhysicalName(2, 3, "PEC")

    gmsh.model.mesh.setSize([(0,108),(0,109)], 0.05)
    gmsh.option.setNumber('Mesh.MeshSizeMin', 0.001)
    gmsh.option.setNumber('Mesh.MeshSizeMax', 1.2)
    gmsh.option.setNumber('Mesh.Algorithm', 6) #1=Mesh Adapt, 2=Auto, 3=Initial mesh only, 5=Delaunay, 6=Frontal-Delaunay
    gmsh.option.setNumber('Mesh.MshFileVersion', 2.2)
    gmsh.option.setNumber('Mesh.Format', 1)
    gmsh.option.setNumber('Mesh.MinimumCirclePoints', 50)
    gmsh.option.setNumber('Mesh.CharacteristicLengthFromCurvature', 1)
    gmsh.model.mesh.generate(3)
    #gmsh.fltk.run()

# mesh = 3d topology
# ct = volume tags
# fm = surface tags
mesh, ct, fm = gmshio.model_to_mesh(gmsh.model, comm, modelRank, gdim=3)
if modelRank == mpiRank:
    gmsh.finalize()

mesh.topology.create_connectivity(mesh.topology.dim-1, mesh.topology.dim)
elem = ufl.FiniteElement('Nedelec 1st kind H(curl)', mesh.ufl_cell(), degree=2)
V = fem.FunctionSpace(mesh, elem)
u = ufl.TrialFunction(V)
v = ufl.TestFunction(V)

# Print out BC tags
with io.XDMFFile(mesh.comm, "BCs.xdmf", "w") as xx:
    xx.write_mesh(mesh)
    xx.write_meshtags(fm)

n = ufl.FacetNormal(mesh)

# Dirichlet BCs
facets = fm.find(3) # PEC facets
ubc = fem.Function(V)
ubc.x.set(0+0j)
dofs = fem.locate_dofs_topological(V, mesh.topology.dim-1, facets)
bc = fem.dirichletbc(ubc, dofs)

# Set up forms for eigenvalue problem Ax -k0^2*Bx = 0
a = fem.form(ufl.inner(ufl.curl(u), ufl.curl(v)) * ufl.dx)
b = fem.form(ufl.inner(u, v) * ufl.dx)

A = fem.petsc.assemble_matrix(a, bcs=[bc])
A.assemble()
B = fem.petsc.assemble_matrix(b, bcs=[bc])
B.assemble()
eigs = slepc.EPS().create(mesh.comm)
eigs.setOperators(A, B)
eigs.setProblemType(slepc.EPS.ProblemType.GHEP) # General hermitian
eigs.setTolerances(1.0e-8)
eigs.setType(slepc.EPS.Type.KRYLOVSCHUR)
st = eigs.getST() # Invoke spectral transformation
st.setType(slepc.ST.Type.SINVERT)
eigs.setWhichEigenpairs(slepc.EPS.Which.TARGET_REAL) # target real part of eigenvalue
eigs.setTarget(-1.0)
eigs.setDimensions(nev=5) # Number of eigenvalues
eigs.solve()
eigs.view()
eigs.errorView()

sys.exit(0)

The mistake is in your import, it should be from slepc4py import SLEPc
and then in turn SLEPc.EPS()

Thanks! Made the change, but get another cryptic error:

Traceback (most recent call last):
  File "/home/bill/Cluster/Fenics2020/Helix/HelicalSection2.py", line 4, in <module>
    from slepc4py import SLEPc
  File "/usr/lib/slepc/lib/python3/dist-packages/slepc4py/SLEPc.py", line 7, in <module>
    SLEPc._initialize()
  File "SLEPc/SLEPc.pyx", line 235, in slepc4py.SLEPc._initialize
  File "SLEPc/SLEPc.pyx", line 211, in slepc4py.SLEPc.register
  File "PETSc/Object.pyx", line 265, in petsc4py.PETSc.PyPetscType_Register
ValueError: key: 1211220, cannot register: <class 'slepc4py.SLEPc.BV'>, already registered: <class 'petsc4py.PETSc.Viewer'>

Modified code is here.

# Generate unit cell of helical structure (no periodic boundary in this case).
import sys
import numpy as np
from slepc4py import SLEPc
from petsc4py import PETSc
from mpi4py import MPI as nMPI
import meshio
import ufl
from dolfinx.mesh import locate_entities_boundary, meshtags
from dolfinx.io import gmshio
from dolfinx import fem
from dolfinx import io
import gmsh

l = 6.0 # Cell length
r = 6.0 # Cell radius
rh = 2.0 # Helix radius
rw = 0.2 # wire radius
npts = 100 # number of points of spline curve
eps = 1.0e-5

Gamma = 0 + 6.283j

comm = nMPI.COMM_WORLD
mpiRank = comm.rank
modelRank = 0 # process where GMSG runs

if mpiRank == modelRank:

    gmsh.initialize()
    gmsh.option.setNumber('General.Terminal', 1)
    gmsh.model.add("Helix Cell")

    c = gmsh.model.occ.addCylinder(0, 0, 0, 0, 0, l, r, 1, 2*np.pi)

    dt = 2 * np.pi / npts
    p = []
    for n in range(npts+3):
        theta = 2 * np.pi * (n-1) / npts
        kk = gmsh.model.occ.addCircle(rh * np.cos(theta), rh * np.sin(theta), (n -1) * l / npts, rw)
        p.append(gmsh.model.occ.addCurveLoop([kk], tag=-1))
    print(p)
    s = gmsh.model.occ.addThruSections(p, tag=-1)
    print(s)
    v = gmsh.model.occ.cut([(3,c)], s, tag=100, removeObject=True, removeTool=True)
    print("v={}".format(v))
    for n in range(npts+3):
        gmsh.model.occ.remove([(1,p[n])], recursive=True)

    gmsh.model.occ.synchronize()

    bb = gmsh.model.getEntities(dim=3)
    pt = gmsh.model.getBoundary(bb, combined=True, oriented=False, recursive=False)
    print(pt)
# Boundary conditions
    Bot = []
    Top = []
    PEC = []
    for bb in pt:
        CoM = gmsh.model.occ.getCenterOfMass(bb[0], bb[1])
        print(CoM)
        if(np.abs(CoM[2]) < eps):
            Bot.append(bb[1])
        elif(np.abs(CoM[2]-l) < eps):
            Top.append(bb[1])
        else:
            PEC.append(bb[1])

    print(Bot, Top, PEC)
    gmsh.model.mesh.setPeriodic(2, Top, Bot, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, l, 0, 0, 0, 1])

    gmsh.model.addPhysicalGroup(3, [100], 1) # Helix volume
    gmsh.model.setPhysicalName(3, 1, "HelixVolume")
    gmsh.model.addPhysicalGroup(2, Top, 1) # Top BC (slave periodic BC)
    gmsh.model.addPhysicalGroup(2, Bot, 2) # Bottom BC (master periodic BC)
    gmsh.model.addPhysicalGroup(2, PEC, 3) # PEC boundary
    gmsh.model.setPhysicalName(2, 1, "TopPBC")
    gmsh.model.setPhysicalName(2, 2, "BotPBC")
    gmsh.model.setPhysicalName(2, 3, "PEC")

    gmsh.model.mesh.setSize([(0,108),(0,109)], 0.05)
    gmsh.option.setNumber('Mesh.MeshSizeMin', 0.001)
    gmsh.option.setNumber('Mesh.MeshSizeMax', 1.2)
    gmsh.option.setNumber('Mesh.Algorithm', 6) #1=Mesh Adapt, 2=Auto, 3=Initial mesh only, 5=Delaunay, 6=Frontal-Delaunay
    gmsh.option.setNumber('Mesh.MshFileVersion', 2.2)
    gmsh.option.setNumber('Mesh.Format', 1)
    gmsh.option.setNumber('Mesh.MinimumCirclePoints', 50)
    gmsh.option.setNumber('Mesh.CharacteristicLengthFromCurvature', 1)
    gmsh.model.mesh.generate(3)
    #gmsh.fltk.run()

# mesh = 3d topology
# ct = volume tags
# fm = surface tags
mesh, ct, fm = gmshio.model_to_mesh(gmsh.model, comm, modelRank, gdim=3)
if modelRank == mpiRank:
    gmsh.finalize()

mesh.topology.create_connectivity(mesh.topology.dim-1, mesh.topology.dim)
elem = ufl.FiniteElement('Nedelec 1st kind H(curl)', mesh.ufl_cell(), degree=2)
V = fem.FunctionSpace(mesh, elem)
u = ufl.TrialFunction(V)
v = ufl.TestFunction(V)

# Print out BC tags
with io.XDMFFile(mesh.comm, "BCs.xdmf", "w") as xx:
    xx.write_mesh(mesh)
    xx.write_meshtags(fm)

n = ufl.FacetNormal(mesh)

# Dirichlet BCs
facets = fm.find(3) # PEC facets
ubc = fem.Function(V)
ubc.x.set(0+0j)
dofs = fem.locate_dofs_topological(V, mesh.topology.dim-1, facets)
bc = fem.dirichletbc(ubc, dofs)

# Set up forms for eigenvalue problem Ax -k0^2*Bx = 0
a = fem.form(ufl.inner(ufl.curl(u), ufl.curl(v)) * ufl.dx)
b = fem.form(ufl.inner(u, v) * ufl.dx)

A = fem.petsc.assemble_matrix(a, bcs=[bc])
A.assemble()
B = fem.petsc.assemble_matrix(b, bcs=[bc])
B.assemble()
eigs = SLEPc.EPS().create(mesh.comm)
eigs.setOperators(A, B)
eigs.setProblemType(SLEPc.EPS.ProblemType.GHEP) # General hermitian
eigs.setTolerances(1.0e-8)
eigs.setType(SLEPc.EPS.Type.KRYLOVSCHUR)
st = eigs.getST() # Invoke spectral transformation
st.setType(SLEPc.ST.Type.SINVERT)
eigs.setWhichEigenpairs(SLEPc.EPS.Which.TARGET_REAL) # target real part of eigenvalue
eigs.setTarget(-1.0)
eigs.setDimensions(nev=5) # Number of eigenvalues
eigs.solve()
eigs.view()
eigs.errorView()

sys.exit(0)

Is it possible that I have a version discrepancy with SLEPc?

I cannot get to that point of your script as I get an error when generating your mesh:

Info    : Reconstructing periodicity for curve connection 107 - 109
Info    : Reconstructing periodicity for curve connection 110 - 111
Error   : Cannot find periodic counterpart of node 2732 of curve 110 on curve 111
Traceback (most recent call last):
  File "/root/shared/mwe12345.py", line 88, in <module>
    gmsh.model.mesh.generate(3)
  File "/usr/local/lib/gmsh.py", line 2006, in generate
    raise Exception(logger.getLastError())

please try to reproduce the problem with a built-in mesh (say a unit cube).

Here is a built-in mesh example and it produces the same error.

EDIT: I should add that entering “from slepc4py import SLEPc” directly into the Python3 interpreter (command line) the error is observed.
SLEPc version is: “python3-petsc4py-complex is already the newest version (3.15.1-2build1)”.

# Test problem for eigensolver
import sys
import numpy as np
from slepc4py import SLEPc
from petsc4py import PETSc
from mpi4py import MPI as nMPI
import meshio
import ufl
from dolfinx.mesh import create_box
from dolfinx import fem
from dolfinx import io

comm = nMPI.COMM_WORLD
mpiRank = comm.rank
modelRank = 0 
w = 1.0
h = 1.0
l = 1.0
nx = 20
ny = 20
nz = 20

msh = create_box(comm, np.array([[0, 0, 0], [w, h, l]]), np.array([nx, ny, nz]), CellType.tetrahedron)

msh.topology.create_connectivity(msh.topology.dim - 1, msh.topology.dim)
elem = ufl.FiniteElement('Nedelec 1st kind H(curl)', msh.ufl_cell(), degree=2)
V = fem.FunctionSpace(msh, elem)
u = ufl.TrialFunction(V)
v = ufl.TestFunction(V)

facets = mesh.exterior_facet_indices(msh.topology)
dofs = fem.locate_dofs_topological(V, msh.topology.dim - 1, facets)
u_bc = fem.Function(V)
with u_bc.vector.localForm() as loc:
    loc.set(0)
bc = fem.dirichletbc(u_bc, dofs)

# Set up forms for eigenvalue problem Ax -k0^2*Bx = 0
a = fem.form(ufl.inner(ufl.curl(u), ufl.curl(v)) * ufl.dx)
b = fem.form(ufl.inner(u, v) * ufl.dx)
A = fem.petsc.assemble_matrix(a, bcs=[bc])
A.assemble()
B = fem.petsc.assemble_matrix(b, bcs=[bc])
B.assemble()
eigs = SLEPc.EPS().create(mesh.comm)
eigs.setOperators(A, B)
eigs.setProblemType(SLEPc.EPS.ProblemType.GHEP) # General hermitian
eigs.setTolerances(1.0e-8)
eigs.setType(SLEPc.EPS.Type.KRYLOVSCHUR)
st = eigs.getST() # Invoke spectral transformation
st.setType(SLEPc.ST.Type.SINVERT)
eigs.setWhichEigenpairs(SLEPc.EPS.Which.TARGET_REAL) # target real part of eigenvalue
eigs.setTarget(-1.0)
eigs.setDimensions(nev=5) # Number of eigenvalues
eigs.solve()
eigs.view()
eigs.errorView()

sys.exit(0)

I cannot reproduce this in docker, so it seems like it is due to your installation.
How did you install it?
Btw. here is the script I’m running:

# Test problem for eigensolver
import sys
import numpy as np
from slepc4py import SLEPc
from petsc4py import PETSc
from mpi4py import MPI as nMPI
import ufl
import dolfinx.fem.petsc
from dolfinx import mesh
from dolfinx.mesh import create_box, CellType
from dolfinx import fem
from dolfinx import io

comm = nMPI.COMM_WORLD
mpiRank = comm.rank
modelRank = 0 
w = 1.0
h = 1.0
l = 1.0
nx = 10
ny = 10
nz = 10

msh = create_box(comm, np.array([[0, 0, 0], [w, h, l]]), np.array([nx, ny, nz]), CellType.tetrahedron)

msh.topology.create_connectivity(msh.topology.dim - 1, msh.topology.dim)
elem = ufl.FiniteElement('Nedelec 1st kind H(curl)', msh.ufl_cell(), degree=2)
V = fem.FunctionSpace(msh, elem)
u = ufl.TrialFunction(V)
v = ufl.TestFunction(V)

facets = mesh.exterior_facet_indices(msh.topology)
dofs = fem.locate_dofs_topological(V, msh.topology.dim - 1, facets)
u_bc = fem.Function(V)
with u_bc.vector.localForm() as loc:
    loc.set(0)
bc = fem.dirichletbc(u_bc, dofs)

# Set up forms for eigenvalue problem Ax -k0^2*Bx = 0
a = fem.form(ufl.inner(ufl.curl(u), ufl.curl(v)) * ufl.dx)
b = fem.form(ufl.inner(u, v) * ufl.dx)
A = dolfinx.fem.petsc.assemble_matrix(a, bcs=[bc])
A.assemble()
B = dolfinx.fem.petsc.assemble_matrix(b, bcs=[bc])
B.assemble()
eigs = SLEPc.EPS().create(msh.comm)
eigs.setOperators(A, B)
eigs.setProblemType(SLEPc.EPS.ProblemType.GHEP) # General hermitian
eigs.setTolerances(1.0e-8)
eigs.setType(SLEPc.EPS.Type.KRYLOVSCHUR)
st = eigs.getST() # Invoke spectral transformation
st.setType(SLEPc.ST.Type.SINVERT)
eigs.setWhichEigenpairs(SLEPc.EPS.Which.TARGET_REAL) # target real part of eigenvalue
eigs.setTarget(-1.0)
eigs.setDimensions(nev=5) # Number of eigenvalues
eigs.solve()
eigs.view()
eigs.errorView()

sys.exit(0)

I installed using the Ubuntu 22.04 PPA (i.e. apt install …).

Could you print:

python3 -c "import petsc4py; print(petsc4py.__version__, petsc4py)"
python3 -c "import slepc4py; print(slepc4py.__version__, slepc4py)"

@dparsons do you have any ideas?:slight_smile:

msh = create_box(comm, np.array([[0, 0, 0], [w, h, l]]), np.array([nx, ny, nz]), CellType.tetrahedron)

NameError: name 'CellType' is not defined

That error has nothing to do with SLEPc.

I’ve Fixed the celltype error in my code snippet, so I guess @BillS would have to give us the full trace of running the code I provided + the info about petsc/slepc

OK, I think I found something. I had a look through the SLEPc installation docs and I saw that the SLEPC_DIR environment variable needs to be set. On my system, no such variable was defined, so I had a look through the directory tree and tried a few settings until the code finally ran to completion.

Setting “export SLEPC_DIR=/usr/lib/slepcdir/slepc-complex” made the code run (even tho’ the solution did not converge). I’m happy that I got somewhere, although I still need to play around with the solver to get it to converge properly.

Thanks for the help!

You shouldn’t need to have to set SLEPC_DIR if you’re using the default build (32 bit integers, real scalars, usually linked to /usr/lib/petsc and /usr/lib/slepc). There are no explicit complex numbers in the test script, apart from using setWhichEigenpairs to get real values, so it’s not obvious that you necessarily need slepc-complex unless your matrix is not hermitian.

But your SLEPC_DIR does need to be consistent with the corresponding PETSC_DIR. If you’ve set PETSC_DIR to one of the alternative builds, then certainly you need to set SLEPC_DIR to match it.

So if you really do need slepc-complex, make sure you also point PETSC_DIR at petsc-complex.

Yes, it is strange that the default did not work. I should have the bog-standard PETSC build. Anyway, it works for the simple parallelpiped resonator case.

# Test problem for eigensolver
import sys
import numpy as np
from slepc4py import SLEPc
from petsc4py import PETSc
from mpi4py import MPI as nMPI
import meshio
import ufl
import dolfinx.fem.petsc
from dolfinx.mesh import create_box, CellType
from dolfinx import fem
from dolfinx import mesh
from dolfinx import io

comm = nMPI.COMM_WORLD
mpiRank = comm.rank
modelRank = 0 
w = 1.0
h = 1.0
l = 1.5
nx = 10
ny = 10
nz = 15

msh = create_box(comm, np.array([[0, 0, 0], [w, h, l]]), np.array([nx, ny, nz]), CellType.tetrahedron)

msh.topology.create_connectivity(msh.topology.dim - 1, msh.topology.dim)
elem = ufl.FiniteElement('Nedelec 1st kind H(curl)', msh.ufl_cell(), degree=3)
V = fem.FunctionSpace(msh, elem)
u = ufl.TrialFunction(V)
v = ufl.TestFunction(V)

facets = mesh.exterior_facet_indices(msh.topology)
dofs = fem.locate_dofs_topological(V, msh.topology.dim - 1, facets)
u_bc = fem.Function(V)
with u_bc.vector.localForm() as loc:
    loc.set(0+0j)
bc = fem.dirichletbc(u_bc, dofs)

# Set up forms for eigenvalue problem Ax -k0^2*Bx = 0
a = fem.form(ufl.inner(ufl.curl(u), ufl.curl(v)) * ufl.dx)
b = fem.form(ufl.inner(u, v) * ufl.dx)
A = fem.petsc.assemble_matrix(a, bcs=[bc])
A.assemble()
B = fem.petsc.assemble_matrix(b, bcs=[bc])
B.assemble()
eigs = SLEPc.EPS().create(msh.comm)
eigs.setOperators(A, B)
eigs.setProblemType(SLEPc.EPS.ProblemType.GHEP) # General hermitian
eigs.setTolerances(1.0e-8)
eigs.setType(SLEPc.EPS.Type.KRYLOVSCHUR)
st = eigs.getST() # Invoke spectral transformation
st.setType(SLEPc.ST.Type.SINVERT)
eigs.setWhichEigenpairs(SLEPc.EPS.Which.TARGET_REAL) # target real part of eigenvalue
eigs.setTarget(-640.0)
eigs.setDimensions(nev=36) # Number of eigenvalues
eigs.solve()
eigs.view()
eigs.errorView()
evs = eigs.getConverged()
eh = fem.Function(V)
W = fem.VectorFunctionSpace(msh, ('Lagrange', 3))
Et = fem.Function(W)

if(mpiRank == 0):
   print( "Number of converged eigenpairs %d" % evs )
   if evs > 0:
       for i in range (evs):
           error = 0.0
           l = eigs.getEigenpair(i, eh.vector)
           if(l.real > 1.0e-3):
                error = eigs.getErrorEstimate(i)
           print(l, error)

if evs > 0:
    for i in range (evs):
        l = eigs.getEigenpair(i, eh.vector)
        if(l.real > 1.0e-3):
            Et.interpolate(eh)
            Et.name = "ElectricField"
# Save solutions
### VTXWriter not found in dolfinx.io
#            with io.VTXWriter(msh.comm, f"Et_{i}.bp", Et_dg) as f:
#               f.write(0.0)            
            with io.XDMFFile(msh.comm, "Efield_{0}.xdmf".format(i), "w") as xx:
                xx.write_mesh(msh)
                xx.write_function(Et)


sys.exit(0)

The eigenvalue set that corresponds to the modes (the non-spurious eigenvalues) are pretty much spot-on with the theoretical values.

EVAL                       Est'd error
(1.7053025658242404e-12+0j) 0.0
(7.435119186993688e-11+0j) 0.0
(8.333245204994455e-11+0j) 0.0
(8.776623872108757e-11+0j) 0.0
(9.333689376944676e-11+0j) 0.0
(1.035687091643922e-10+0j) 0.0
(0.9999999999974989+0j) 4.5521757279890876e-15
(0.9999999999996589+0j) 6.152096803851861e-12
(1.0000000000001137+0j) 3.34756694528909e-13
(1.0000000000005684+0j) 5.168855653203259e-10
(1.0000000000010232+0j) 1.4313572052591264e-10
(14.256095367289959+0j) 1.0175270919599893e-09
(14.256095567914485+0j) 2.5748572155290087e-10
(19.739209703843244+0j) 8.879701548245225e-17
(24.125702528960915+0j) 8.797910158171856e-12
(24.125702628405747+0j) 4.273701046133593e-11
(27.415569607926273+0j) 7.242430802574129e-12
(27.415572304525767+0j) 5.5062137699561386e-12
(37.28518901411462+0j) 1.407663286890302e-16
(37.28518909657737+0j) 3.601878973945912e-16
(43.86492014128237+0j) 4.24698919091773e-12
(43.86492016102784+0j) 9.66546798590204e-12
(49.348036551090445+0j) 5.203157905033643e-17
(49.348043964573776+0j) 1.2939034295160203e-14
(49.34805232555527+0j) 1.922951778787589e-14
(49.348059849270726+0j) 9.465095705578627e-16
(53.73453634801024+0j) 6.593107641633483e-13
(53.734551816657586+0j) 2.957028335346582e-13
(53.73457355350911+0j) 3.380082004090528e-13
(53.73459462458766+0j) 5.711809977179114e-14
(57.0244366852595+0j) 7.467753308748761e-18
(57.02443671169226+0j) 1.775301867613393e-18
(59.21771319507582+0j) 1.6372639662179294e-17
(59.21771363617552+0j) 2.6928365147543697e-18
(66.89406047235502+0j) 3.689256561482374e-10
(66.89410077426737+0j) 3.8144634019712137e-10
(66.89418236313008+0j) 1.4680842044962838e-09
(66.89421364612383+0j) 3.766701674503899e-10
(78.95706048659429+0j) 3.3533748144881018e-09
(78.95706059142276+0j) 9.984940204305672e-10
(80.05352650115947+0j) 7.237045288046595e-12
(80.0536727918493+0j) 1.0146502680544889e-11
(83.34365201730691+0j) 4.6336223779801335e-10
(83.3436930046746+0j) 5.537450430677245e-10

My problem now is to get good plots of the eigenmodes. The plotted fields look almost right, but there is some irregularity on the boundary surfaces. I suppose I am not doing something correctly.


Field should look nice and smooth on the boundary surface, but there are numerous nonphysical artifacts (sudden orange-blue jumps) visible.

I will start a new topic if the discussion of this proceeds beyond a couple of responses.

hi BillS,
With the code you mentioned, I’ve the following error. Can you say why is like that?

…/fenicsx-env/lib/python3.12/site-packages/dolfinx/fem/function.py", line 378, in _
self._cpp_object.interpolate(u._cpp_object, cells, nmm_interpolation_data)
RuntimeError: Interpolation: elements have different value dimensions

I cannot reproduce your error message. What version of DOLFINx are you running?

The only place I get an error is at outputting:

Traceback (most recent call last):
  File "/root/shared/ping.py", line 88, in <module>
    xx.write_function(Et)
  File "/usr/local/dolfinx-complex/lib/python3.10/dist-packages/dolfinx/io/utils.py", line 235, in write_function
    super().write_function(getattr(u, "_cpp_object", u), t, mesh_xpath)
RuntimeError: Degree of output Function must be same as mesh degree. Maybe the Function needs to be interpolated?

which is described in TypeError: BoundingBoxTree.__init__() takes 2 positional arguments but 3 were given - #4 by dokken

hi,
I’m using the latest version of DOLFINx https://docs.fenicsproject.org/dolfinx/v0.7.3/python/.
Thanks.

Im using that through docker (docker run -ti -v $(pwd):/root/shared -w /root/shared --rm ghcr.io/fenics/dolfinx/dolfinx:v0.7.3 ), and cannot reproduce the error. Please explain how you installed dolfinx, what
dolfinx.__version__
and dolfinx.common.git_commit_hash is.