How to use the min function?

Please make this a minimal code example for anyone to have a look at. As you are missing all the definitions of u_1 and q_s, there is no way telling what is causing the error. See: Read before posting: How do I get my question answered? - #4 by nate for examples of minimal coding examples