Getting started with FEM using sfepy

404 views
Skip to first unread message

Sergey Dolgov

unread,
Mar 1, 2008, 3:57:19 PM3/1/08
to sfepy-devel
Hi Robert, Ondrej, others.

For some time now I've been planing to learn finite element method
with the purpose of applying it to electrostatic problems arising in
field emission calculations. I'm also fond of free software tools.
I've been thinking of using libmesh, which seems to be rather
powerful, but currently I would say that it is too hardcore for me,
given how weak my knowledge of C++ is; plus I don't yet need advanced
capabilities like parallel computation.

So while reading about sympy, I've stumbled upon sfepy, and I feel
optimistic about it because 1) it looks like a still relatively simple
implementation, and 2) it is wrtten mostly in Python (I've got some
experience with Python, numpy, scipy, matplotlib).

What sfepy is lacking is of course documentation. I've read some
introductory texts on FEM, but certainly don't feel knowledgeable
enough to figure how to use sfepy right away. I wold say I need to
close the gap between pure theory and sfepy implementation. Thus I've
got two questions:

* Do you think that using sfepy to learn FEM in general is a good
idea? (By "using sfepy to learn FEM" I mean 1) learning how to
describe the problem so that sfepy can solve it and 2) learning how
sfepy actually works so that I can actually make modifications myself)

* What book would you recommend as a guide to studying FEM (is there
one that sfepy implementation follows more closely than the others)?

Sorry if my questions look silly -- they certainly do to me :)

Nonetheless, thanks for the great work!

--
Sergey

Ondrej Certik

unread,
Mar 1, 2008, 5:17:56 PM3/1/08
to sfepy...@googlegroups.com
Hi Sergey!

Thanks for the feedback. I am glad that sympy is also useful in a way
to build the community of people doing scientific calculations.
Together with scipy + numpy + matplotlib, we want to have a nice
environment for doing basically anything. The community around all
these
these tools is wonderful.

To learn about FEM, you can try my notes here:

http://libmesh.sourceforge.net/wiki/index.php/Main_Page#Examples

mainly this:

http://ondrej.certik.cz/site_media/libmesh/fem.ps

Let me know if it is useful and if you don't understand something, just ask.

As to doing electrostatics, that is perfectly possible with sfepy. But
the documentation is missing, you need to read the sources directly.
From my own experience, sfepy is much easier to use than libmesh, but
that's because I know already Python and also because Robert helped me
write the solver for things that I needed. I think you won't loose
time learning it. If you decided you don't like it, you can always
write something on your own.

Right now I am actually in Austin at the Enthought headquarters, it's
awesome to discuss things directly with people like Fernando
(ipython), Travis (numpy). So while I am here I will visit the libmesh
guys here and definitely discuss ways of doing FEM with them.

Ondrej

Robert Cimrman

unread,
Mar 3, 2008, 5:12:18 AM3/3/08
to sfepy...@googlegroups.com
Hi Sergey!

Ondrej Certik wrote:
> Hi Sergey!
>
> On Sat, Mar 1, 2008 at 9:57 PM, Sergey Dolgov <sol...@gmail.com> wrote:
>> Hi Robert, Ondrej, others.
>>
>> For some time now I've been planing to learn finite element method
>> with the purpose of applying it to electrostatic problems arising in
>> field emission calculations. I'm also fond of free software tools.
>> I've been thinking of using libmesh, which seems to be rather
>> powerful, but currently I would say that it is too hardcore for me,
>> given how weak my knowledge of C++ is; plus I don't yet need advanced
>> capabilities like parallel computation.
>>
>> So while reading about sympy, I've stumbled upon sfepy, and I feel
>> optimistic about it because 1) it looks like a still relatively simple
>> implementation, and 2) it is wrtten mostly in Python (I've got some
>> experience with Python, numpy, scipy, matplotlib).

Yes, sfepy is very simple comparing to e.g. libmesh. The released
package has about 350kB including example meshes and other data.
However, it can already be used to solve various kinds of non-trivial
problems, as you have probably seen on the Examples page. The web was
not updated for some time, but we are now preparing new pages, so wait a
bit for more up-to-date stuff.

>> What sfepy is lacking is of course documentation. I've read some
>> introductory texts on FEM, but certainly don't feel knowledgeable
>> enough to figure how to use sfepy right away. I wold say I need to

Yes this definitely needs to be addressed. Until recently I have
developed sfepy alone, and as I tried to keep the code clear and simple,
I did not need to write the documentation. Now that other people start
joining or showing interest, this will change of course. I have to thank
Ondrej for his feedback.

>> close the gap between pure theory and sfepy implementation. Thus I've
>> got two questions:
>>
>> * Do you think that using sfepy to learn FEM in general is a good
>> idea? (By "using sfepy to learn FEM" I mean 1) learning how to
>> describe the problem so that sfepy can solve it and 2) learning how
>> sfepy actually works so that I can actually make modifications myself)

SfePy uses problem description files (input files) that resemble in
structure to a mathematical description of a weak FE formulation on
paper - you define fields of certain FE spaces (e.g. linear P1),
variables, equations etc. But you have to know already some basics of
FEM to understand the notions at least. The notes Ondrej pointed you to
below are a good start. Look also at

http://ui505p06-mbs.ntc.zcu.cz/sfe/Documentation?action=AttachFile&do=get&target=terms.pdf

where a very brief information on how to solve a Poisson equation in
sfepy. I will improve this soon and put it on the web.

A general info on FEM can be found on many places, e.g. here:
http://en.wikipedia.org/wiki/Finite_element_method

>> * What book would you recommend as a guide to studying FEM (is there
>> one that sfepy implementation follows more closely than the others)?

Well, I have no real preference here. Any book about FEM is ok.

>> Sorry if my questions look silly -- they certainly do to me :)

No, these are good questions - nobody starts as an expert :-)

If you have some specific questions, just ask - I can help you get running.

>> Nonetheless, thanks for the great work!
>
> Thanks for the feedback. I am glad that sympy is also useful in a way
> to build the community of people doing scientific calculations.
> Together with scipy + numpy + matplotlib, we want to have a nice
> environment for doing basically anything. The community around all
> these
> these tools is wonderful.

+1.

And then you find out that the guy doing similar things lives next town...

> To learn about FEM, you can try my notes here:
>
> http://libmesh.sourceforge.net/wiki/index.php/Main_Page#Examples
>
> mainly this:
>
> http://ondrej.certik.cz/site_media/libmesh/fem.ps
>
> Let me know if it is useful and if you don't understand something, just ask.
>
> As to doing electrostatics, that is perfectly possible with sfepy. But
> the documentation is missing, you need to read the sources directly.
>>From my own experience, sfepy is much easier to use than libmesh, but
> that's because I know already Python and also because Robert helped me
> write the solver for things that I needed. I think you won't loose
> time learning it. If you decided you don't like it, you can always
> write something on your own.

But I would like to have more people working with sfepy, giving feedback
and helping improving it!

> Right now I am actually in Austin at the Enthought headquarters, it's
> awesome to discuss things directly with people like Fernando
> (ipython), Travis (numpy). So while I am here I will visit the libmesh
> guys here and definitely discuss ways of doing FEM with them.

Say hello to the *py* people!

r.

Ondrej Certik

unread,
Mar 5, 2008, 8:02:03 PM3/5/08
to sfepy...@googlegroups.com

I did and I also advertized sfepy a lot. Did you experience any
difference in site statistics? :)

When I find some time, I'll write all my experiences here to my blog.

Ondrej

Robert Cimrman

unread,
Mar 6, 2008, 4:19:21 AM3/6/08
to sfepy...@googlegroups.com
Ondrej Certik wrote:
>> > Right now I am actually in Austin at the Enthought headquarters, it's
>> > awesome to discuss things directly with people like Fernando
>> > (ipython), Travis (numpy). So while I am here I will visit the libmesh
>> > guys here and definitely discuss ways of doing FEM with them.
>>
>> Say hello to the *py* people!
>
> I did and I also advertized sfepy a lot. Did you experience any
> difference in site statistics? :)

Yep :-)

> When I find some time, I'll write all my experiences here to my blog.

My second name is curious!

Concerning the documentation, I can write a chapter on FEM w.r.t. sfepy
first after 16.3., as now we are preparing a grant project and it makes
me very busy. Tomorrow evening we leave to Chamonix to enjoy some snow,
so next week I will be off-line.

r.

osman

unread,
Mar 7, 2008, 7:59:29 PM3/7/08
to sfepy-devel


On Mar 1, 3:57 pm, Sergey Dolgov <sol...@gmail.com> wrote:
> Hi Robert, Ondrej, others.
>
> For some time now I've been planing to learn finite element method
> with the purpose of applying it to electrostatic problems arising in
> field emission calculations. I'm also fond of free software tools.
> I've been thinking of using libmesh, which seems to be rather
> powerful, but currently I would say that it is too hardcore for me,
> given how weak my knowledge of C++ is;

Hi Sergey,
I would also suggest to look at pyDolfin of Dolfin project at
fenics.org. Also for electrostatics netgen/ngsolve has the
capability to accept variational weak form version of the PDE and
mesh/postprocess all in one program with a GUI with examples in
electrostatics. Also their docs might help too.
br,
-osman
Reply all
Reply to author
Forward
0 new messages