Rework sensitivity calculation approach
Description of the problem
Sensitivities should be computed on a set of fields w.r.t. another set of fields. For example, in the graph below, we may want to compute sensitivities of {a,b,c} w.r.t. {x,y}.
A few things to note:
- We should end up with no sensitivities calculated on α, β and 𝜙.
- dc/dx = 0, and should be calculated as such without propagating this through the graph (short-circuited)
- db/dy should generate sensitivities on g but should results in zero sensitivities on de/dy and df/dy so that the chain rule can be properly performed on db/dy.
Key steps:
-
Parse the graph and identify nodes which have sensitivities, nodes which must have zero sensitivities on them, and nodes which have no sensitivities required at all. -
Create a mechanism for an expression to calculate a zero sensitivity. -
Don't throw an exception on an expression sensitivity
method for expressions where sensitivity is not required. -
On time integrator updater expressions and convergence measure expressions, don't implement an empty sensitivity method; rather implement one that throws an exception since this is undefined behavior. -
When a zero sensitivity expression is created, we need to ensure proper execution ordering. This implies that it should be attached to the value expression.
This should replace the current sensitivity calculation mechanism, which is insufficiently general.
This also supersedes issue #42 (closed) which will be irrelevant once this is done.
Thanks to @mahanse, who helped formulate the requirements here.