Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Limits for FE analysis

Status
Not open for further replies.

Stazz

Structural
Oct 22, 2008
100
0
0
US
Has anyone tried using excel for a Finite Element Analysis? I've done it with a small structural frame when I was in school but I'm wondering if excel is able to invert a large 1000x1000 matrix. I know the minverse function can only handle up to about n=256 so I'm wondering if there is a way to compile and invert the matrix on the VBA side of excel. Thanks.
 
Replies continue below

Recommended for you

Of course there is. Just look it up in any numerical recipe book and convert the algorithm to VBA.

Whether it solves in a reasonable time is a whole separate issue.

Cheers

Greg Locock

SIG:please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Thanks. So whats a good, efficient numerical method? Anyone have any recommendations or refferences? Would a sparse accellerator be good? How does that work? Anyone have this code they want to share?
 
With FE the matrix is banded so there's no need to invert a square matrix, but use a banded solver instead. You'd have to use an algorithm to reorder the node numbers to minimise the bandwidth first. You can find these in lots of text books if you look around.

Excel will be slow though as the code isn't compiled. I've written a Boundary Element code in excel before with a square matrix of typically 100 x 100. The solve time of milliseconds is too slow for some these days.

corus
 
> The solve time of milliseconds is too slow for some these days.

:)

Try a freeware C or Fortran compiler - that´s the most straightforward route to fast home-made FE. Expect VBA in Excel to be horribly slow for your application. I was shocked when I wrote a small dof radiation solver recently.
 
I think it is a good idea to link VBA in Excel to C code. Beside the fact that C is fast, there are state of the art sparse solvers such as superLU that are free. I don't recommend you to write a linear solver of your own.

Yes, you can link VBA to C codes. A colleague of mine just presented in a group meeting a few months ago the way to do it. I just remember that it is not very straight forward, nothing else.

If you code in Matlab, you can link to C and Fortran also. But again it is not very straightforward. You'll need to write gateway functions to pass parameters back and forth. But actually, Matlab linear solver is not too bad. It can handle, say, 10,000 dofs pretty fast.

Have a good time coding!


 
You may find the articles from my blog listed below of use:





I found it considerably easier to get Fortran routines linked to Excel than C, but that may be because I'm not that familiar with C. Either should work well, once you gety the system sorted out.

Also whilst VBA is undoubtedly much slower that Fortran or C, for many applications it will be more than fast enough.

Doug Jenkins
Interactive Design Services
 
" Expect VBA in Excel to be horribly slow for your application. I was shocked when I wrote a small dof radiation solver recently."

VBA is slower than a compiled program, but it shouldn't be that slow. Two of the main things that can be done to speed things up is to make sure that all the data is transferred into VBA at once, as arrays rather than cell by cell, and avoid using worksheetfunction in the VBA code. This applies particularly in Excel 2007.

Doug Jenkins
Interactive Design Services
 
FWIW inverting a 1000 by 1000 matrix of random numbers in Octave, using a compiled standard maths library, took 2 seconds, Matlab would be the same or faster I should think. I didn't try the same using a sparse matrix as the reordering problem is a little more complex than I can be bothered with today.




Cheers

Greg Locock

SIG:please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Further to my earlier post, VBA is about 6 times slower than a Fortran dll linked to Excel, using the same algorithm. I don't know if Greg's computer is much faster than mine, or if he has a superfast algorithm (or both), but my Fortran code took about 9 seconds to do Gaussian elimination and back substitution on 1000x1000 random numbers. A C++ dll was a little slower.

Excel 2007 will invert a 1000 x 1000 matrix using the minverse() function, and takes about the same time as the VBA.

If you do use VBA the way to read the numbers into a VBA array is:

1: create a variant variable
2: Read the data into this variable:
vbaarray = range("datarange").value2
3: This will create an array of variants. For less maths intensive applications it is usually best to leave it at that, but in this case it is worth creating a new array of type double, and reading the contents of the variant array into the double array. As far as I know, the only way to do that is:

Redim vba_double_array(1 to numrows, 1 to numcols)
for i = 1 to numrows
for j = 1 to numcols
vba_double_array(i,j) = vbaarray(i,j)
next j
next i

Doug Jenkins
Interactive Design Services
 
Status
Not open for further replies.
Back
Top