Hello everyone
I was using FEniCS to solve a 1D peridynamics problem. The exact problem statement is as follows-
A rod extends from (alpha = 0) to (beta = 1m) and is subjected to body force (b(x)) of 1N/m and the equation is solved for displacement with BCs as u(0) = 0 and u(1) = 0 and delta is a parameter. The variational form for the same is :
$$\frac{1}{\delta^2}$$ $$ \int_{\alpha}^{\beta}v(x) \int_{x - \delta}^{x + \delta} \frac{u(x) - u(x’)}{|x-x’|} dx’ dx = \int_{\alpha}^{\beta}v(x) b(x) dx $$
with v being the weight function
Within the outside integral of variational form, we have another inner integral for a dummy variable x’.
How is that to be coded in FEniCS?
My sample code looks like this:
from fenics import *
import sympy as sy
alpha,beta,delta = 0,1,0.3
no_elem,degree = 2,1
mesh = IntervalMesh(no_elem, alpha, beta)
def boundary_1(x,on_boundary):
return on_boundary and near(x[0],0,DOLFIN_EPS)
def boundary_2(x,on_boundary):
return on_boundary and near(x[0],1,DOLFIN_EPS)
V = FunctionSpace(mesh, "CG", degree)
u = TrialFunction(V)
v = TestFunction(V)
body_force = Constant(1.0)
y1 = sy.Symbol('y1')
i = Expression(' (u(x[0]) - u(y1)) / abs (x[0] - y1) ', degree = 2)
a = v*Expression('(sy.integrate(i,(y1,x[0] - delta, x[0] + delta))/delta**2)', degree = 2)
L = body_force*v*dx
u = Function(V)
bcs = [DirichletBC(V, Constant(0.0), boundary_1), DirichletBC(V, Constant(0.0), boundary_1)]
solve(a == L, u, bcs)
The error message I get is -
The version I m using is dolfin 2019.2.0 (developed version) in Spyder3 notebook in a Linux Subsystem on Windows
PS : My apologies for posting the error as an image, but for some reason Spyder won’t allow me to copy and paste the error here or anywhere else. (I had to write the code manually)
Any lead and help is in formulation of the weak form is highly appreciated. Thanks in advance!