1 /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- */
5 * This source code is part of
9 * GROningen MAchine for Chemical Simulations
11 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
12 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
13 * Copyright (c) 2001-2008, The GROMACS development team,
14 * check out http://www.gromacs.org for more information.
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * If you want to redistribute modifications, please consider that
22 * scientific software is very special. Version control is crucial -
23 * bugs must be traceable. We will be happy to consider code for
24 * inclusion in the official distribution, but derived work must not
25 * be called official GROMACS. Details are found in the README & COPYING
26 * files - if they are missing, get the official version at www.gromacs.org.
28 * To help us fund GROMACS development, we humbly ask that you cite
29 * the papers on the package - you can find them in the top README file.
31 * For more info, check our website at http://www.gromacs.org
34 * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon
44 static bool ip_pert(int ftype
,t_iparams
*ip
)
49 if (NRFPB(ftype
) == 0)
62 bPert
= (ip
->harmonic
.rA
!= ip
->harmonic
.rB
||
63 ip
->harmonic
.krA
!= ip
->harmonic
.krB
);
68 bPert
= (ip
->pdihs
.phiA
!= ip
->pdihs
.phiB
||
69 ip
->pdihs
.cpA
!= ip
->pdihs
.cpB
);
73 for(i
=0; i
<NR_RBDIHS
; i
++)
75 if (ip
->rbdihs
.rbcA
[i
] != ip
->rbdihs
.rbcB
[i
])
85 bPert
= (ip
->tab
.kA
!= ip
->tab
.kB
);
91 if (ip
->posres
.pos0A
[i
] != ip
->posres
.pos0B
[i
] ||
92 ip
->posres
.fcA
[i
] != ip
->posres
.fcB
[i
])
99 bPert
= (ip
->lj14
.c6A
!= ip
->lj14
.c6B
||
100 ip
->lj14
.c12A
!= ip
->lj14
.c12B
);
104 gmx_fatal(FARGS
,"Function type %s not implemented in ip_pert",
105 interaction_function
[ftype
].longname
);
111 bool gmx_mtop_bondeds_free_energy(const gmx_mtop_t
*mtop
)
113 const gmx_ffparams_t
*ffparams
;
117 ffparams
= &mtop
->ffparams
;
119 /* Loop over all the function types and compare the A/B parameters */
121 for(i
=0; i
<ffparams
->ntypes
; i
++)
123 ftype
= ffparams
->functype
[i
];
124 if (interaction_function
[ftype
].flags
& IF_BOND
)
126 if (ip_pert(ftype
,&ffparams
->iparams
[i
]))
133 return (bPert
? ilsortFE_UNSORTED
: ilsortNO_FE
);
136 void gmx_sort_ilist_fe(t_idef
*idef
)
138 int ftype
,nral
,i
,ic
,ib
,a
;
149 iparams
= idef
->iparams
;
151 for(ftype
=0; ftype
<F_NRE
; ftype
++)
153 if (interaction_function
[ftype
].flags
& IF_BOND
)
155 ilist
= &idef
->il
[ftype
];
156 iatoms
= ilist
->iatoms
;
161 while (i
< ilist
->nr
)
163 /* The first element of ia gives the type */
164 if (ip_pert(ftype
,&iparams
[iatoms
[i
]]))
166 /* Copy to the perturbed buffer */
167 if (ib
+ 1 + nral
> iabuf_nalloc
)
169 iabuf_nalloc
= over_alloc_large(ib
+1+nral
);
170 srenew(iabuf
,iabuf_nalloc
);
172 for(a
=0; a
<1+nral
; a
++)
174 iabuf
[ib
++] = iatoms
[i
++];
180 for(a
=0; a
<1+nral
; a
++)
182 iatoms
[ic
++] = iatoms
[i
++];
186 /* Now we now the number of non-perturbed interactions */
187 ilist
->nr_nonperturbed
= ic
;
189 /* Copy the buffer with perturbed interactions to the ilist */
192 iatoms
[ic
++] = iabuf
[a
];
197 fprintf(debug
,"%s non-pert %d pert %d\n",
198 interaction_function
[ftype
].longname
,
199 ilist
->nr_nonperturbed
,
200 ilist
->nr
-ilist
->nr_nonperturbed
);
207 idef
->ilsort
= ilsortFE_SORTED
;