Hi guys,
I'm working on a larger project, solving non-linear differential equation systems by calculating the steady states.
I want to create a very flexible script were I enter a n-dimensional equation system (mostly n=3).
The script calculates the steady states and does a stabilty analysis and will have a latex file output.
The main part of the script is working. (see test.py or test.sh for compiling the latex code)
But I face two problems I can't solve.
My first problem is also discussed here:
https://groups.google.com/forum/#!topic/sympy/ebGJLKeMODQAll Variables of the System (here X,Y,Z) should be >= 0.
If you look at the last steady state in the latex file, the expressions for Y,Z are quite uncomfortable because of the negative sign.
(1, -(\RXZ*\RZY + \RZY + 1)/(\RYZ*\RZY - 1), -(\RXZ + \RYZ + 1)/(\RYZ*\RZY - 1))
So I would like to replace these expression by
(1, (\RXZ*\RZY + \RZY + 1)/(1 - \RYZ*\RZY ), (\RXZ + \RYZ + 1)/(1 - \RYZ*\RZY ))
If you also have a look at the diagonal elements J_2,2 and J_3,3 of the jacobian matrix.
These elements could be replaced by a much shorter term like -\RY*\Y for J_2,2 and -\RZ*\Z for J_3,3.
But the function sympy.subs() doesn't work in this case because of the negative sign of the solutions of Y and Z
I think I could solve this problem if I can transform
(1, -(\RXZ*\RZY + \RZY + 1)/(\RYZ*\RZY - 1), -(\RXZ + \RYZ + 1)/(\RYZ*\RZY - 1))
to
(1, (\RXZ*\RZY + \RZY + 1)/(1 - \RYZ*\RZY ), (\RXZ + \RYZ + 1)/(1 - \RYZ*\RZY ))
as written above.
Do you know how to transform these lines ?
My second problem is the analysis of the calculated eigenvalues of the jacobian matrix. If all eigenvalues are negative, there is a stable steady state.
The problem is that the eigenvalues can be a number or an expression. For numbers I can easily ask with an if statement, if they are negative.
For the expressions I found the function
solve_univariate_inequality()
but it doesn't seem very robust if I have a longer expressions with a lot of unknown positive constants.
Is there any function which solves ineualities with a flexible amount of input data?
Sorry for this long text and thank you in advance for your answers!
Alex