Ry10
Ry10

Reputation: 87

Specifying unknowns in check_total_derivatives

I am creating a Unitest for a program I have written in OpenMDAO v1.x+. I have been using the check_total_derivatives function to get the derivatives and to check them in comparison to finite difference. However, I only care about checking the six or so final unknowns, but I have about 90 in total. Would it be possible to add an option to the check_total_derivatives function to specify what unknowns you want the function to check? Right now it takes a very long time to go through everything. I created this functionality in my own version of OpenMDAO but this program is intended for other users that will not have this functionality unless it is built in.

Upvotes: 1

Views: 33

Answers (1)

Kenneth Moore
Kenneth Moore

Reputation: 2202

We have a way to do this now. If you specify any constraints or objectives on unknowns by calling add_constraint or add_objective on a driver, and then subsequently call check_total_derivatives, it will only calculate derivatives for those unknowns. Similarly, if you specify design variables with add_desvar, it will calculate derivatives with respect to just those inputs.

This feature was mainly added because you may want to check the gradient that the optimizer sees. If you aren't doing optimization, the API still lets you add constraints, etc. to the basic Driver; this shouldn't change the execution, but still allows you to limit the scope of check_total_derivatives.

Note, I think your request still stands as a good feature request -- just wanted to give a workaround for now.

Upvotes: 1

Related Questions