Hello eveyone, I am trying to use nsolve of sympy to find solutions of system of non-linear algebraic equations. My system has three non-linear equations with three unknowns. Each of these equations also has an input parameter 'V' which I specify explicitly.
i = 7.0 NLE_1 = Nonlinear_eq_1.subs(V, i) NLE_2 = Nonlinear_eq_2.subs(V, i) NLE_3 = Nonlinear_eq_3.subs(V, i)
As said earlier, Nonlinear_eq_1, Nonlinear_eq_2 and Nonlinear_eq_3 are functions of a1, a2 and a3. Now this non-linear system has upper threshold value of V. I need to find out this critical V value and which is the actual unknown that I am interested in.
For given system parameters, I have tried to zoom in on the critical V value as follows:
In the beginning, I iterated i manually (without employing any looping e.g., for loop) so that it increases from 0 with increment of 1. Using the following line of code, I found out the roots of the system of non-linear equations:
ans_nonlinear = smp.nsolve([NLE_1, NLE_2, NLE_3], [a1, a2, a3], linear_answers)
where, 'linear_answers' is a tuple which is obtained by solving the Nonlinear_eq_1, Nonlinear_eq_2 and Nonlinear_eq_3 by only considering linear terms involving a1, a2, a3 as follows:
ans_linear = smp.solve((LE_1, LE_2, LE_3), (a1, a2, a3)) linear_answers = (float(ans_linear.get(a1)), float(ans_linear.get(a2)), float(ans_linear.get(a3)))
Now, from V = 0 till V = 7, I got definite answers for ans_nonlinear. However, when V = 8, nsolve gave the following error:
**Could not find root within given tolerance. (2.16855306310932770901e-19 > 2.16840434497100886801e-19) Try another starting point or tweak arguments. **
This error is indirectly stating that V has a critical value inbetween 7 and 8.
I wanted to know how to use this error so that I can raise a user-defined flag and suppress the error as well. I am intending on using this flag so that I can then go back to V = 7 and start incrementing V as 7.1, 7.2, 7.3 etc. Using this logic in a loop, I will then hone in on the critical value of V to the desired accuracy.
I kindly request the help of other users so that this query can be handled. This problem is basically on finding out static pull-in instability parameters of micro-cantilevers using three-mode reduced order model (ROM).
#python #sympy #scipy #nsolve