Fix placement of writing composite/star terms

Fix placement of writing composite/star terms to the output file.
Modify placement of torque computation

Modify placement of `compute_torque` in `composite_inverse_dynmodel()`.