Solving linear by non-linear solver


374
views
1
12 months ago by
Hi all,

I am trying to solve linear elasticity equation with thermal strain component using non-linear solver. I expect it to converge in one iteration. Please find the code below. I am using dolfin of version 1.6-0. I am getting the following error
Form has no parts with arity 2.
No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F'.
Solving nonlinear variational problem.
Newton iteration 0: r (abs) = 2.569e-01 (tol = 1.000e-10) r (rel) = 1.000e+00 (tol = 1.000e-09)
Traceback (most recent call last):
File "one_way.py", line 61, in <module>
solve(wf== 0, w, bc)
File "/usr/lib/python2.7/dist-packages/dolfin/fem/solving.py", line 297, in solve
_solve_varproblem(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/dolfin/fem/solving.py", line 345, in _solve_varproblem
solver.solve()



from dolfin import *
import numpy as np
from mshr import *


L=1;Width=0.2
mu=1
rho=1
delta=Width/L
gamma=.4*delta**2
beta=1.25
lambda_=beta
g=gamma
deltaTemp=100;alpha=1;

mesh=UnitSquareMesh(2,2)
V=VectorFunctionSpace(mesh,'P',2)

fixedge=Constant((0.0,0.0))
pulledge=Constant((1.0,0.0))
tol=1e-4

def clamped(x,on_boundary):
return on_boundary and (x[0] < tol)

bc1=DirichletBC(V,Constant((0,0)),clamped)
bc=[bc1]

def epsilon(u):
return 0.5*(nabla_grad(u) + nabla_grad(u).T)

def sigma(u):
return lambda_*nabla_div(u)*Identity(2) + 2*mu*epsilon(u) -alpha*deltaTemp*Identity(2)


u=Function(V)
v=TestFunction(V)
f = Constant((1, 0))
a = inner(grad(u), grad(v))*dx
L = inner(f, v)*dx
wf=a+L

w=Function(V)
# Compute solution
solve(wf== 0, w, bc)​
Community: FEniCS Project

2 Answers


5
12 months ago by
Hi Peter,

your residual form wf is defined for a function u, which is the function for which you want to find a solution. Function w in your example is completely unrelated to the problem. Just replace the last line with solve(wf == 0, u, bc). (And you can delete w=Function(V).) This should work.

PS: Be aware of wrong indentation of the return lines in your post.
0
12 months ago by
Hi,

Works perfectly fine! Thanks!
Please login to add an answer/comment or follow this question.

Similar posts:
Search »