### Adjoint - Dirichlet BC

204

views

0

Hi!

I am trying to solve an optimization problem using IPOPT. When the definition of BC is made using classes, optimiztion runs well. When the definition is made using functions, I get the following error:

The problem is that with the function use, I can reach convergence and, with classes, I can not make the problem converge (note that they are the same problem).

Any ideas?

Thanks?

Okubo

I am trying to solve an optimization problem using IPOPT. When the definition of BC is made using classes, optimiztion runs well. When the definition is made using functions, I get the following error:

```
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 699, in runfile
execfile(filename, namespace)
File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 81, in execfile
builtins.execfile(filename, *where)
File "/home/okubo/Desktop/Source_sink_tests/Elbow_2_Source_sink_opt.py", line 121, in <module>
dJdma_init = compute_gradient(J,ma)
File "/home/okubo/.local/lib/python2.7/site-packages/pyadjoint/drivers.py", line 26, in compute_gradient
tape.evaluate()
File "/home/okubo/.local/lib/python2.7/site-packages/pyadjoint/tape.py", line 106, in evaluate
self._blocks[i].evaluate_adj()
File "/home/okubo/.local/lib/python2.7/site-packages/pyadjoint/tape.py", line 41, in wrapper
return function(*args, **kwargs)
File "/home/okubo/.local/lib/python2.7/site-packages/fenics_adjoint/types/dirichletbc.py", line 100, in evaluate_adj
adj_output.append(adj_value.sub(i, deepcopy=True).vector().sum())
File "/usr/lib/python2.7/dist-packages/dolfin/functions/function.py", line 355, in sub
% num_sub_spaces)
RuntimeError: Can only extract subfunctions with i = 0..2
```

The problem is that with the function use, I can reach convergence and, with classes, I can not make the problem converge (note that they are the same problem).

Any ideas?

Thanks?

Okubo

Community: FEniCS Project

Please login to add an answer/comment or follow this question.

did you solve your problem? I have a similar problem that Dirichlet boundary in adjoint gave me same error info.