This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Best way to compute many sensitivities using dolfin-adjoint

0 votes

Hi Everyone, I have a simple linear elliptic problem where the source term has many parameters. I can use dolfin-adjoint to get the sensitivity of a functional to all of them and it's working great. However I'm doing it this way:

for i in range(0, 10):
    dJdm = compute_gradient(J, m[i], forget=False)
    print float(didm)

Every time compute_gradient is called the adjoint problem is solved. Is there a more efficient way, where the adjoint problem is solved once and the sensitivities are computed from the adjoint variables? I looked through the dolfin-adjoint documentation and tutorials but couldn't find something that addresses this directly.

Thanks,
Dave

closed with the note: Issue resolved
asked Aug 6, 2016 by david.bernstein FEniCS User (2,000 points)
closed Aug 9, 2016 by david.bernstein

1 Answer

0 votes

This seems to work and solve the adjoint problem only once:

dJdm = compute_gradient(J, m)

It produces an array of sensitivities given the functional J and an array of Control parameters.

answered Aug 9, 2016 by david.bernstein FEniCS User (2,000 points)
...