I have been building an optimal control simulation similar to the racecar example from the documentation (https://openmdao.org/dymos/docs/latest/examples/racecar/racecar.html). In my model there is a vehicle dynamics model that calculates the accelerations in the vehicle reference frame, based on the forces produced by the tires and the current velocities of the vehicle.
The tire forces are calculated by a second component that takes the vehicle velocities (states) and applied torques (controls) using simple linear relations (longitudinal force scales linearly with torque, lateral force scales with slip angle). Finally there is a third component that calculates the grip limits of the tire based on a friction circle. See the XDSM below:
XDSM
When I try to run this I get a restoration failure from IPOPT. Checking the total derivatives against complex step gives me this output:
'traj.phase0.collocation_constraint.defects:r' | 'traj.phase0.states:n' | 9.8677e-02 | 9.8723e-02 | 3.0820e-03 | 3.1218e-02 | >ABS_TOL >REL_TOL |
+---------------------------------------------------+-------------------------+-------------+-------------+-------------+-------------+--------------------+
| 'traj.phase0.collocation_constraint.defects:r' | 'traj.phase0.states:r' | 1.0607e+01 | 1.0607e+01 | 2.3431e-03 | 2.2091e-04 | >ABS_TOL >REL_TOL |
+---------------------------------------------------+-------------------------+-------------+-------------+-------------+-------------+--------------------+
| 'traj.phase0.collocation_constraint.defects:r' | 'traj.phase0.states:u' | 7.0988e-02 | 7.1729e-02 | 4.4107e-03 | 6.1491e-02 | >ABS_TOL >REL_TOL |
+---------------------------------------------------+-------------------------+-------------+-------------+-------------+-------------+--------------------+
| 'traj.phase0.collocation_constraint.defects:r' | 'traj.phase0.states:v' | 2.7646e-02 | 2.9618e-02 | 3.5225e-03 | 1.1893e-01 | >ABS_TOL >REL_TOL |
+---------------------------------------------------+-------------------------+-------------+-------------+-------------+-------------+--------------------+
| 'traj.phase0.collocation_constraint.defects:r' | 'traj.phase0.states:xi' | 1.6765e+00 | 1.6593e+00 | 5.8082e-02 | 3.5004e-02 | >ABS_TOL >REL_TOL |
+---------------------------------------------------+-------------------------+-------------+-------------+-------------+-------------+--------------------+
| 'traj.phase0.collocation_constraint.defects:v' | 'traj.phase0.states:n' | 1.3974e+00 | 1.3982e+00 | 7.9276e-03 | 5.6700e-03 | >ABS_TOL >REL_TOL |
+---------------------------------------------------+-------------------------+-------------+-------------+-------------+-------------+--------------------+
| 'traj.phase0.collocation_constraint.defects:v' | 'traj.phase0.states:r' | 4.4467e+01 | 4.4466e+01 | 6.6054e-03 | 1.4855e-04 | >ABS_TOL >REL_TOL |
+---------------------------------------------------+-------------------------+-------------+-------------+-------------+-------------+--------------------+
| 'traj.phase0.collocation_constraint.defects:v' | 'traj.phase0.states:u' | 7.9225e-01 | 7.9746e-01 | 1.1748e-02 | 1.4732e-02 | >ABS_TOL >REL_TOL |
+---------------------------------------------------+-------------------------+-------------+-------------+-------------+-------------+--------------------+
| 'traj.phase0.collocation_constraint.defects:v' | 'traj.phase0.states:v' | 1.0619e+01 | 1.0620e+01 | 9.0666e-03 | 8.5377e-04 | >ABS_TOL >REL_TOL |
+---------------------------------------------------+-------------------------+-------------+-------------+-------------+-------------+--------------------+
| 'traj.phase0.collocation_constraint.defects:v' | 'traj.phase0.states:xi' | 1.2890e+01 | 1.2893e+01 | 1.3847e-01 | 1.0740e-02 | >ABS_TOL >REL_TOL |
+---------------------------------------------------+-------------------------+-------------+-------------+-------------+-------------+--------------------+
I have checked all the partials using the complex step method as was done in the baristochrome example and they should all be correct.
When I merge the vehicle dynamics and tire force calculation blocks into one block the optimisation runs great and there are no problems whatsoever. This led me to think that there might have been missing information about the partial derivatives of the slip angles that are used to caclulate the tire force, thus I tried moving the slip angle calculation to the TireForce component. This did not solve the issue however so there might be something else going wrong here.