Coding (new) Engines : Python or C++ ?

Asked by Jérôme Duriez

Hello,

I'm planning to write a new Engine (for my personnal use, since it is quite specific, see below), and I'm wondering what is the best choice regarding the speed of computations : calling from times to times a Python function, or using an usual Engine coded in C++ ?

If necessary, here is some description of the tasks to be performed : it is about a parallelepipedic sample (of spheres) whose I want to control the lateral stress. Since the wanted stresses are not uniform along the height of the sample, I will control directly the spheres of the external layer, instead using a boundary box as in classical Triaxial engines. So, more or less each time the engine is executed, there will be a loop over all considered spheres. And for each sphere, a "global stifness" has to be derived (=> loop over interactions, cf Triaxial engines), before the sphere is displaced. So, it may be long...

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jérôme Duriez
Solved:
Last query:
Last reply:
Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#1

Hi Jerome,
If I guess correctly, you will have also to detect which spheres are
part of the outer layer periodicaly.
At the end of the day it sounds like a lot of loops on engines and
interactions, so I would consider c++ implementation for production.
You can use python for designing the algorithm, however. It will be simpler.

Bruno

Revision history for this message
Anton Gladky (gladky-anton) said :
#2

Hi Jerome,

I would also recommend C++ implementation. The most suitable place, I think
is a Shop_*.cpp.

I have recently spitted it into 2 parts to escape memory exhaust during
building Yade
on i386 with gcc-4.8. Feel free to add your code into Shop_02 or create a
new
Shop_03, if you want.

Please, do not forget to describe, what the code does + references (if any)
+ example.

Thanks

Anton

2013/11/19 jduriez <email address hidden>

> New question #239457 on Yade:
> https://answers.launchpad.net/yade/+question/239457
>
> Hello,
>
> I'm planning to write a new Engine (for my personnal use, since it is
> quite specific, see below), and I'm wondering what is the best choice
> regarding the speed of computations : calling from times to times a Python
> function, or using an usual Engine coded in C++ ?
>
> If necessary, here is some description of the tasks to be performed : it
> is about a parallelepipedic sample (of spheres) whose I want to control the
> lateral stress. Since the wanted stresses are not uniform along the height
> of the sample, I will control directly the spheres of the external layer,
> instead using a boundary box as in classical Triaxial engines. So, more or
> less each time the engine is executed, there will be a loop over all
> considered spheres. And for each sphere, a "global stifness" has to be
> derived (=> loop over interactions, cf Triaxial engines), before the sphere
> is displaced. So, it may be long...
>
>
>
> --
> You received this question notification because you are a member of
> yade-users, which is an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>

Revision history for this message
Jérôme Duriez (jduriez) said :
#3

Ok, thanks to both of you ! You confirm that the execution should be faster through C++, or did you have other reasons in mind ?

Bruno : for info, at the moment, I deal with a fixed list of spheres belonging to lateral boundaries (so there will be no detection step, regarding what you said)
Anton : at the moment I do not plan to commit this function, because it seems to me unlikely that it could be useful for something else than my current simulations.. So maybe I could avoid to overcrowd Shop !