[Top][All Lists]

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

Re: [ESPResSo] Fwd: bonds

From: Axel Arnold
Subject: Re: [ESPResSo] Fwd: bonds
Date: Tue, 13 Jul 2010 12:27:27 +0200
User-agent: KMail/1.10.3 (Linux/; KDE/4.1.3; x86_64; ; )

On Monday 12 July 2010 22:55:41 Mikheil Azatov wrote:
> far. In the code when I check if the distance and angle between particles
> satisfies some conditions to add the bond between them I also want to check
> if this bond already exists. Since when I add bond the particles will
> always stay close to each other and the code as right now will try to add
> bond between them every integration step. As I understood the information
> about the bonds of the particles contains in p->bl. Looking at utils.h I
> found that p->bl->e is an IntLinst and b->bl->e should contain the
> information about what bond and with what particles does particle p have.

Well, p->bl is the bond list, and p->bl->e its contents, but otherwise, you 
are right :-).
> So as I understand p->bl->e[0] is bond_id and p-bl->e[1] ,
> p->bl->e[2],...,p->bl->e[p->bl->n] because as I understood p->bl->n
> contains number elements in array p->bl->e[].
> Is this correct ? If yes, how information is stored for particle with more
> then 1 bond ?

The different bonds are simply stored one after the other. So, if you have a 
pair bond of type 1 to particle 6, and an angle of type 2 with particles 3 and 
5, the list will have 5 elements: 1,6,2,3,5. That works, since the bond type 
also determines how many particles this bond needs.

To go through all bonds of a particle, use a loop like this:

int i;
while(i<p->bl.n) {
    int type_num = p->bl.e[i++];
    int type = bonded_ia_params[type_num].type;
    // array with the bond partners and their count
    int partners = p1->bl.e + i;
    int n_partners = bonded_ia_params[type_num].num;
    .......... /* do your checks if this is the required bond */
    i += n_partners;

If you make sure that you save your angle potentials always such that partner 
1 has the smaller index than partner 2, then it should be fairly easy to 
search if the corresponding bond already exists or not.


JP Dr. Axel Arnold Tel: +49 711 685 67609
ICP, Universit├Ąt Stuttgart      Email: address@hidden
Pfaffenwaldring 27
70569 Stuttgart, Germany

reply via email to

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