Thanks for the responses! Your comments prompted me to revisit the global matrix. I was able to reduce complexity by eliminating some of the exponentials using the Matrix.col function. Passing the solved integration constants onto the function to be integrated was too expensive so I decided to calculate these constants at every integration step. This has significantly reduced solution time. I'm working to reduce further. Thanks again.
Andre http://paste.pocoo.org/show/294439/ On Thu, Nov 18, 2010 at 11:36 AM, Aaron S. Meurer <[email protected]>wrote: > I get the same thing. For the first expression, I get > > In [69]: sz.count_ops() > Out[69]: 11378 + 9866⋅POW + 17655⋅ADD + 61510⋅MUL > > So like Ondrej said, the solution here is not necessarily Cython, but to > find an algorithm for solving that Matrix equation that gives a simpler > solution. Of course, this is all assuming that the solution can be > simplified. If it really can't then there is no way around the costs of > dealing with such large expressions. > > But even then, you can be smarter than what you are doing now. simplify() > is a general simplification function that can be slow. Since you know the > form of the input expression, you can get away with calling lesser > simplification functions. From what I could glean from your expression, > cancel() should be sufficient. But even then, calling cancel on just A0 > causes my computer to hang. > > By the way, a more Pythonic way to write > > for i in range(len(E)): > mu.append(E[i]/(2*(1+nu[i]))) > > is > > for i, j in zip(E, nu): > mu.append(i/(2*(1 + j))) > > Aaron Meurer > > On Nov 18, 2010, at 12:06 AM, Ondrej Certik wrote: > > > Hi Andre, > > > > On Wed, Nov 17, 2010 at 8:29 PM, freevryheid <[email protected]> > wrote: > >> Hi > >> > >> I’m on a mission to code an open source elastic multi-layer analysis > >> system to calculate stress, strain and displacement response in > >> layered systems to surface loads. As proof of concept I opted to use > >> sympy and coded a simple two layer system under a single circular load > >> [1]. The vision is to eventually solve a system with many layers and/ > >> or loads. Most of the solution time appears to be in simplifying the > >> functions before integration - this step is necessary to avoid > >> division by zero errors (for example). Will performance improve using > >> Cython? Any other suggestions? > > > > I tried your script and it hangs for me in the first simplify function > > print. I just tried to print the expression and it takes forever. What > > is the structure of the expressions? I tried print A0, and it's many > > pages. > > > > Can this be simplified? Can some other method be used instead of the LU > solve? > > > > It seems that the expression is very big, so even things like expand() > > take forever. What kind of simplification is necessary --- maybe it's > > just expand? If so, maybe things can be expanded before they grow big > > (either use a different method than LU, or expand things before you > > pass it in). > > > > Ondrej > > > > -- > > You received this message because you are subscribed to the Google Groups > "sympy" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > [email protected] <sympy%[email protected]>. > > For more options, visit this group at > http://groups.google.com/group/sympy?hl=en. > > > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected] <sympy%[email protected]>. > For more options, visit this group at > http://groups.google.com/group/sympy?hl=en. > > -- Andre -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
