evaluate_functional yields in some cases wrong functional
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
dolfin-adjoint |
Fix Committed
|
Undecided
|
Unassigned |
Bug Description
During the development of ReducedFunctional I struggled with functionals that integrate over time periods, e.g.
Functional(
A closer look suggests that there is a problem with the time evaluation. To demonstrate this, I wrote a simple problem (code is attached) that first runs two timesteps (dt = 1.0) and integrates the functional manually. It then uses the ReducedFunctional and the functional_
Here is the output:
+++++++++++++ INITIAL RUN +++++++++
Functional contribution at timestep 0.0 : 0.0
Functional contribution at timestep 1.0 : 2.0
Functional contribution at timestep 2.0 : 8.0
Manually computed functional value: 5.0
+++++++++++++ REPLAY +++++++++
Functional contribution at timestep 0 from reduced functional: 1.0
Functional contribution at timestep 1 from reduced functional: 6.0
Functional value from reduced functional: 7.0
Of course they should yield the same answer...
I should mention that this code requires the lp:~libadjoint/dolfin-adjoint/improved-optimisation branch to run