Error during solving my problem

Hello everyone
When I run this program, I get an error.
can you please check why I get it.

1
2

from fenics import *

Lx = 5         # length of system along x-axis
Ly = 10        # length of system along y-axis
n_ele = 10     # number of element

mesh = RectangleMesh(Point( 0 , -Ly/2 ) , Point(Lx, Ly / 2) , n_ele , n_ele)

domains = MeshFunction("size_t", mesh, 2)
V      = FunctionSpace(mesh, "Lagrange", 1)
f       = TrialFunction(V)
g      = TestFunction(V)

def boundary(x):
    tol = 1E-14
    return near(x[0], 0, tol)

bc = DirichletBC(V, 0.0, boundary)

r  = Expression("x[0] ", degree = 1)
l  = Expression("5 / x[0]" , degree=1)

a = r * (inner(nabla_grad(f), nabla_grad(g)) + 5 * f * g) * dx + l * f * g * dx

b  = r * f * g * dx
H = PETScMatrix()
M = PETScMatrix()

assemble(a, tensor=H)
bc.apply(H)
assemble(b, tensor=M)
bc.apply(M)

# Create eigensolver for generalized EVP
eigensolver = SLEPcEigenSolver(H, M)
eigensolver.parameters["spectrum"] = "smallest magnitude"
eigensolver.parameters["solver"] = "lapack"
eigensolver.solve()
r, c, rx, cx = eigensolver.get_eigenpair(0)

print("lambda",r)

Please format the code properly by encapsulating it with ```, such that it is readable and runnable for others.

Additionally, please add the error message you are receiving

1 Like

Thank you for your response, the error that I get is below.

*** -------------------------------------------------------------------------

*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at


*** fenics-support@googlegroups.com


*** Remember to include the error message listed below and, if possible,
*** include a minimal running example to reproduce the error.


*** -------------------------------------------------------------------------
*** Error: Unable to extract eigenpair from SLEPc eigenvalue solver.
*** Reason: Requested eigenpair (0) has not been computed.
*** Where: This error was encountered inside SLEPcEigenSolver.cpp.
*** Process: 0


*** DOLFIN version: 2019.1.0
*** Git changeset: 15b823f2c45d3036b6af931284d0f8e3c77b6845
*** -------------------------------------------------------------------------

Process finished with exit code 1

Can you define what each term is and what it is a function of…?

1 Like

I think the problem is related to the divergent of m / x , when x takes 0 so m / x takes a infinite value.
My question rises from here , how I can add a condition as follows, x = 0 => u(0) = 0. ?

You can modify your domain, excluding x=0, as done in 1D in this post: Coupled linear problem solves to give NaN? (Describes curvature flows)

You can Also remove the singularity by multiplying all terms by x.

1 Like