Elucidating and Leveraging Dynamics-Function Relationships in Neural Circuits through Modeling and Optimal Control