Hello Everyone,
I am new to Fenics, I installed the Fenics it was working for me a day before. However, I am getting this run time error (attached image) which was not there for the same code.
The used code for this test is the following
from fenics import * #to import FEniCS library
from mshr import * #to import library for meshing
import matplotlib.pyplot as plt #to import matlab plotting library
from ufl import nabla_div #to import library for the calculation of nabla divergence
# Define Data
E = 210000.0
nu = 0.3
lambda_1 = (E*nu)/((1+nu)*(1-2*nu))
mu_1 = E/(2*(1+nu))
#Define and plot mesh
domain = Rectangle(Point(0.0, 0.0), Point(100.0, 100.0))
mesh = generate_mesh(domain, 32)
print(mesh.num_cells())
plot(mesh)
plt.show()
# Define function space
V = VectorFunctionSpace(mesh, 'P', 1)
# Define Boundary Conditions
# Dirichlet BC
tol = 1E-14
# finding nodes on bottom edge
def boundary_D_y(x, on_boundary):
return on_boundary and near(x[1], 0, tol)
# finding node of bottom left cornor
def boundary_D_x(x, on_boundary):
return near(x[1], 0, tol) and near(x[0], 0, tol)
bc_y = DirichletBC(V.sub(1), Constant(0), boundary_D_y)
bc_x = DirichletBC(V, Constant((0, 0)), boundary_D_x, method='pointwise')
#print ('here',bc_x.get_boundary_values())
#print ('here_',bc_y.get_boundary_values())
bcs = [bc_y, bc_x]
# Neumann BC
# finding nodes on top edge
class boundary_N_y(SubDomain):
def inside(self, x, on_boundary):
return on_boundary and near(x[1], 100, tol)
# Definition changes in the ds for Neuman BC
boundary_markers = MeshFunction("size_t", mesh, mesh.topology().dim()-1, 0)
B_N_Y = boundary_N_y()
B_N_Y.mark(boundary_markers, 1)
ds = Measure('ds', domain=mesh, subdomain_data=boundary_markers)
# Define stress and strain relations with displacement
def epsilon(u):
return 0.5*(nabla_grad(u) + nabla_grad(u).T)
def sigma(u):
return lambda_1*nabla_div(u)*Identity(d) + 2*mu_1*epsilon(u)
# Solution definition and
u = TrialFunction(V)
d = u.geometric_dimension()
v = TestFunction(V)
T = Constant((0, 100)) # Applied load
a = inner(sigma(u), epsilon(v))*dx
L = dot(T, v)*ds(1)
u = Function(V)
solve(a == L, u, bcs)
I have checked recent updates in my system and the following one is the recent and seems to me that its linked with the Fenics
2024-03-04 16:40:40 install libdolfin2019.2gcc13:amd64 <none> 2019.2.0~legacy20240219.1c52e83-2~ppa1~jammy1
Thank you
Roshan