espressomd-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ESPResSo-devel] Thoughts from the last coding day


From: Florian Weik
Subject: Re: [ESPResSo-devel] Thoughts from the last coding day
Date: Tue, 30 Jun 2015 17:46:32 +0200

Henri,
position is mandatory in Espresso. Momentum / velocity is not meaningful for all types of simulations (BD, MC, ...),
we don't want to do that.

Cheers,
Florian

On Tue, Jun 30, 2015 at 5:01 PM, Henri Menke <address@hidden> wrote:
Thank you Gary for posing this interesting question!
Here are my opinions.

# TL;DR version:

Issue 1) A particle handle should correspond to a physical particle and
position and velocity should be set upon construction.
Issue 2) I don't really think there is an over-use of Cython, but if
there is we should aim to make the code consistent and convert all
not-yet-Cython code.

# Long version:

Issue 1) I totally agree with you that a particle handle should
correspond to a physical particle.  As in mechanics a particle is
described by its phase space coordinates “position” and “momentum”, I
further propose to have a mandatory argument for the particle
constructor which is the position.  Also this constructor should set the
particle velocity, either as an optional argument or default to zero (I
guess most people assign velocity to the particles by means of
interactions among them, so zero would be okay for me).

Issue 2) Regarding the suspected over-use of Cython, I can only
contribute few points.
* All code for the Cython/Python interface I wrote only makes use of
“cdef” to fix the types of variables which are then passed to the C/C++
functions of ESPResSo.
* One could argue about the speedup promised by Cython and that we
should ditch plain Python code for the sake of performance.  This does
not really hold for simple statements where even a speedup factor of 10
is negligible due to the fast evaluation on a plain Python level.
Cluttering the code with “cdef” to exploit every last bit of speedup
makes it unreadable and should be avoided, unless…
* As by now most of the code is annotated with “cdef” we could also get
rid of plain Python code and strive for consistency, which I would prefer.

I hope this is helpful.
Kind regards, Henri

On 06/30/2015 04:11 PM, Gary Davies wrote:
> Dear All
>
> I wanted to talk about this at the last espresso meeting, but
> unfortunately I was away doing my PhD exam.
>
> I thought maybe I'd highlight some of my thoughts about what I saw in
> the python interface that we can discuss over email before the next
> coding day and perhaps briefly at the next coding day.
>
> I implemented an iterator/generator function that allows the user to do
> something like:
>
> for p in S.part:
>    bla bla bla
>
> However, I haven't yet pushed the changes because I don't feel that it
> really does what we would ideally like it to do.
>
> Issue 1) It's possible to create a particle handle without creating a
> physical particle in the system. Since S.part is a (somewhat) a list of
> particle handles, this is troublesome because in the iterator you loop
> through a list of particle handles rather than particles. Therefore, if
> you request a property from the particle handle and the particle does
> not exist, an exception is thrown.
>
> I personally don't see this as desirable behaviour, but I want to hear
> arguments for and against.
>
> My suggestion is to change the constructor of the ParticleHandle class
> such that it must accept the relevant parameters in order to
> successfully initialise a particle. Interesting to hear your thoughts on
> this.
>
> Issue 2) The potential over-use of Cython.
>
> In my opinion, one of the big attractions of using Python as the
> espresso interface is the increased readability and simplicity of python
> code. Cython significantly reduces this readability and simplicity, IMO.
> However, it seems that everything is written in Cython by default
> without regard for whether it actually speeds up the code significantly.
> Ideally we should be writing everything in native python and only
> cythonising the performance bottlenecks.
>
> Is there a reason that everything is by default cython and not native
> python? Perhaps I have misunderstood something fundamental to the python
> interface here.
>
> That's about all I can remember for now.
>
> Interested to hear your opinions on the above 2 issues.
>
> Best wishes, Gary





--
Florian Weik

address@hidden
++49 157 85939252


reply via email to

[Prev in Thread] Current Thread [Next in Thread]