For instance Here I have delta for point force, based on my understanding value is the force x0 is the position of force applied. I am expecting a change in the displacement when I change x0 but there is no change. Is my understanding is correct? if not how can I fix this code?
from dolfin import *
from ufl import nabla_div
import numpy as np
from dolfin import *
# Load mesh and define function space
L =10.
W = 1.
# Mesh for cantilever beam
Omega = BoxMesh(Point(0, 0, 0), Point(L, W, W),100, 3, 3)
#Omega.init()
V = VectorFunctionSpace(Omega, "CG", 1)
tol = 1.e-8 # tolerance
#Dirichlet on left boundary
def l_boundary(x, on_boundary):
return on_boundary and near(x[0], 0.0)
class Delta(UserExpression):
def __init__(self, eps, x0, **kwargs):
print("init function")
self.eps = eps
self.x0 = x0
UserExpression.__init__(self, **kwargs)
def eval(self, values, x):
eps = self.eps
values[0] = 0
values[1] = 0
values[2] = -1
def value_shape(self):
return (3, )
delta = Delta(eps=1E-4, x0=[-0,-0.,-10], degree=3)
zero = Constant((0.0, 0.0, 0.0))
bc = DirichletBC(V, zero, l_boundary)
u = TrialFunction(V)
v = TestFunction(V)
f = Constant((0.0, 0., -1.0))
# Elasticity parameters
E = 1e5
nu = 0.3
mu, lmbda = Constant(E/(2*(1 + nu))), Constant(E*nu/((1 + nu)*(1 - 2*nu)))
# Strain
def eps(u):
return sym(grad(u))
model = "plane_stress"
mu = E/2/(1+nu)
lmbda = E*nu/(1+nu)/(1-2*nu)
if model == "plane_stress":
lmbda = 2*mu*lmbda/(lmbda+2*mu)
def sigma(u):
return lmbda*tr(eps(u))*Identity(3) + 2.0*mu*eps(u)
# Define variational problem
a = inner(sigma(u), eps(v))*dx
l= dot(f, v)*dx +dot(v,delta)*ds
# Compute solution
u = Function(V)
solve(a == l, u, bc)
print("Maximal deflection:", -u(L,0.5,0.5)[2])