All published worksheets from http://sagenb.org
Image: ubuntu2004
Hi there!
I am engineer dealing with nonlinear dynamical systems. I made a spkg for Assimulo so that I can reach the Sundials solvers, particularly IDA (see thread on sage-devel).
I am doing models which depend on the modal-shapes of a structure to describe it's motion.
The model is built symbolically, and the size of the problem grows according to the number of modes used.
Everything is working fine, but too slow. I am looking for ways to speedup the evaluation/substitution on symbolic matrices and vectors.
It seems that fast_float and fast_callable is not available for these cases. In my opinion, this case Fortran seems much simpler than Cython.
My first idea was to translate the symbolic system of equation into Fortran and attach them back via f2py. The idea is to build a translator to compile symbolic entities which are to be evaluated numerically (intensively).
Here I made a simple comparison and illustration of a use case.
In this case simple case you see an improvement of at least 3 orders of magnitude.
Just to mention that Maxima has a f90 translator, but it is very limited. It pretty much does a print() to a file.
How can I build such a translator?
- The solver expects numpy.array at the input and output of user defined residual and jacobian functions.
- Floats must me decorated by the Fortran precision
- Nice if we can pass arrays of parameters instead of long lists of dummy variables
- Observe the 0-based Python to 1-based Fortran.
- Observe the 1**2 instead of 1^2.
I would like to do:
- Automate the translation of the sybolic system to a f2py equivalent.
Comparing the implementations: