Solving the adjoint problem with respect the variable which isnt explicitly in equation
I am trying to solve an optimization problem with dolfin- adjoint. my Elastic madules disribution is a RBF function and it is a function of the coordinate. when I try to find one of this parameters I recive this error.
Traceback (most recent call last):
File "/home/
tol=2e-044, bounds = [(0,0.01)
File "/usr/lib/
opt = algorithm(
AttributeError: 'float' object has no attribute 'data'
my goal is to find the XCenter which is in the experesion which define E. the
I can solve this problem with the constant E but I cant solve it when E is function.here is the code : the first part of the problem is forward problem and the second part is inverse problem.
from __future__ import division
from dolfin import *
from dolfin_adjoint import *
import pickle
import numpy, scipy.io
import csv
print scipy.__version__
parameters[
#######FORWARD PROBLEM
Magnitude=
po=2700
nu = 0.3
NumMeshX=100
NumMeshY=NumMeshX
NumMeshZ=1
Divide=1/NumMeshX
NumofSensor=10
DivideSensor=
lengthplate=1
LoadVector = 0.7
BCLocVec=0.6
w=[100]
matrixH = numpy.zeros(
mesh=UnitSquare
V = VectorFunctionS
XCenterT=0.4
YCenterT=0.4
DepthT=0.001;
PercentT=0.9;
E0T=69000000000
for ww in range(0,len(w)):
top = Top()
# Initialize mesh function for boundary domains
bc = DirichletBC(V, (0.0, 0.0), boundaries,4)
# Define new measures associated with the interior domains and exterior boundaries
ds = Measure(
# Define trial and test functions
u1 = TrialFunction(V)
v = TestFunction(V)
f = Expression(("0.0", "scale"), w0 = w[ww], scale = Magnitude )
mu1 = E1 / (2.0*(1.0 + nu))
def sigma(u):
a = inner(sigma(u1), sym(grad(v)))*dx -po*w[ww]*w[ww] *inner(v,u1)*dx
L = inner(f,v)*ds(2)
u1 = Function(V)
#####INVERSE PROBLEM#
#######
XCenter=
YCenter=
Depth=0.005;
Percent=0.1;
E0=69000000000-
for ww in range(0,len(w)):
top = Top()
# Initialize mesh function for boundary domains
bc = DirichletBC(V, (0.0, 0.0), boundaries,4)
# Define new measures associated with the interior domains and exterior boundaries
ds = Measure(
# Define trial and test functions
u2 = TrialFunction(V)
v = TestFunction(V)
f = Expression(("0.0", "scale"), w0 = w[ww], scale = Magnitude )
# here is the term that Cause the problem##########
mu = E / (2.0*(1.0 + nu))
def sigma(u2):
a = inner(sigma(u2), sym(grad(v)))*dx -po*w[ww]*w[ww] *inner(v,u2)*dx
L = inner(f,v)*ds(2)
u2 = Function(V)
cc=u2-u1
print cc
J = Functional(
reduced_functional = ReducedFunction
m_opt = minimize(
plot(m_opt, mesh,interactiv
any suggestion how can I solve this Error?
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Simon Funke
- Solved:
- Last query:
- Last reply: