# [SciPy-user] FEM

Ryan Krauss ryanlists@gmail....
Sat Mar 17 10:08:41 CDT 2007

```I think the question is a good one and very appropriate when you
consider the potential risk you are taking and the amount of time it
could take to really learn all you need to know to make a truly
informed decision.  I switched from Matlab to
Scipy/Numpy/Matplotlib/Mayavi/IPython half way through my Ph.D. work
and it was a great decision.  But, I didn't do any FEA in Python.
F2py makes using native FORTRAN code very easy.  Google for Python
FEA/FEM.  I know I have run across some packages, but I have never
looked at it in detail.

I have never been able to quantify it (others have had some success),
but in my experience, Python code is much easier to write and debug
than Matlab code.  As a simple example, if I need to operate on every
item in a vector (and can't come up with a good vectorized solution),
in Matlab I need to write

for i in length(vector),
item = vector(i);
{do something with item}
end

where in Python it is just

for item in vector:
{do something with item}

That is a really simple example, but it shows to areas where Matlab
enables me to introduce bugs:
1. If I have nested for loops, I might screw up the indices (i,j,k,...)
2. It lets me overwrite the imaginary number i

I lost countless hours of productivity chasing down those inds of
bugs.  (You only make the i as index mistake once or twice).

And don't get me started about making sure you remember the stinking
semicolons....

FWIW,

Ryan

On 3/16/07, Bill Baxter <wbaxter@gmail.com> wrote:
> Howdy, I don't do FEA, but the things I do are not so different.
> You might find the matlab comparison web page useful:
>    http://www.scipy.org/NumPy_for_Matlab_Users
> Since I wrote a lot that page, I won't repeat the pros and cons
> arguments here in detail, but rather refer you to that page.
>
> Here's a quick summary of what I see to be the highlights:
> * Python/Numpy/Scipy are much better when it comes to the language
> itself and software development aspects, integrating with native code
> in C/C++/Fortran, and applying spot-optimizations.
>
> * Matlab is better (for now) when it comes to graphical debugging.
> * Matlab is better (for now) when it comes to finding free code to
> solve standard mathematical problem X.
> * Matlab is better when it comes to profiling.
>
> But keep on evangelizing.  As far as I see it, the advantages of
> Python are intrinsic (it's based on a good language with broad
> community), whereas Matlab's are temporary and derive primarily from
> having a large head start.
>
> Finally, especially for academia I think the licensing terms are a
> very important consideration.
>
> --bb
>
> On 3/17/07, Håkan Jakobsson <hakan.jakobsson@gmail.com> wrote:
> > Hi list,
> > Python/scipy newbie here. I'm currently writing my master's thesis in
> > computational mathematics - discontinuous galerkin methods to be
> > precise. I'v been doing all the numerics for my thesis in Matlab but
> > stumbled upon Python and scipy by chance. As a little experiment I
> > translated one of my solvers into Python using numpy, scipy and the
> > pysparse packages, and I was very impressed with the effort/performance
> > ratio. Now, to the point..
> >
> > If you're doing finite element analysis, what are you're experiences
> > using Python? Do you use Python as your main development tool? In
> > conjunction with C, Fortran? Is there any drawbacks with using Python
> > for this type of work? Anything else?
> >
> > I hope I'm not asking to much here, but it would be really interesting
> > to know a bit about what the situation's like. I think Python and scipy
> > is really great, and now I'm trying to convince everyone else...
> >