Computing derivatives of implicit functions

Main message

Computing derivatives of implicit functions can seem quite confusing at first, but it is not markedly harder than computing derivatives of explicit functions. Instead of getting d_outputs/d_inputs, you simply need to get d_residuals/d_inputs and d_residuals/d_outputs.

from IPython.display import YouTubeVideo; YouTubeVideo('hNShzL9miAA', width=1024, height=576)

Note

This lesson is most relevant if you’re using the OpenMDAO framework, but if you’re not there should still be value for you here. The video lesson also has a code example walkthrough using OpenMDAO.

We need derivatives of the residual functions

If there’s only one point from this lesson that you remember I want it to be this: for implicit functions we need to compute derivatives of the residual functions. Implicit components in OpenMDAO made a lot more sense to me once I internalized that! Let’s talk bout it.

First, review Explicit vs. Implicit Systems to better understand the differences between implicit and explicit components. Whereas explicit components have outputs that are simply functions of the inputs, implicit components depend on both the inputs and outputs. The way we solve for implicit variables is by converging the residuals of the system. Once converged, the output variables (also known as state variables) will be the correct values.

What this means for derivative computation is that we simply need to compute partial derivatives of the residuals with respect to the inputs and partials of the residuals with respect to the outputs. This might seem counter-intuitive, but the quite simplified explanation is that the solver cares about what the residual equation is and is trying to get that to 0. In an optimization context, we need to know the sensitivity of the residual as we change design variables, as this is what ultimately effects the converged state variable values.

Other resources already cover these ideas in more complete detail. Sections 6.7-6.9 in Engineering Design Optimization details the theoretical basis for obtaining derivatives of implicit functions. The OpenMDAO docs for ImplicitComponent show the actual implementation and methods needed to compute implicit derivatives.

This lesson purposefully doesn’t get deep into the details of the derivatives of implicit functions as there are many topics to cover, including what to do for large systems, sparse Jacobians, systems where you’re running multiple cases with similar state values, etc. I hope to simply introduce the idea of implicit functions and how to get their derivatives.

Explained example of getting derivatives

In the video, I first anchor our discussion by looking at the OpenMDAO docs for ExplicitComponents, then dive into the docs for ImplicitComponents. Look at those pages and follow along!