4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
11 * Copyright (c) 1991-2001, University of Groningen, The Netherlands
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * If you want to redistribute modifications, please consider that
18 * scientific software is very special. Version control is crucial -
19 * bugs must be traceable. We will be happy to consider code for
20 * inclusion in the official distribution, but derived work must not
21 * be called official GROMACS. Details are found in the README & COPYING
22 * files - if they are missing, get the official version at www.gromacs.org.
24 * To help us fund GROMACS development, we humbly ask that you cite
25 * the papers on the package - you can find them in the top README file.
27 * For more info, check our website at http://www.gromacs.org
30 * GROningen Mixture of Alchemy and Childrens' Stories
32 static char *SRCID_convparm_c
= "$Id$";
46 static void assign_param(t_functype ftype
,t_iparams
*new,
47 real old
[MAXFORCEPARAM
])
52 for(j
=0; (j
<MAXFORCEPARAM
); j
++)
53 new->generic
.buf
[j
]=0.0;
57 /* Post processing of input data: store cosine iso angle itself */
58 new->harmonic
.rA
=cos(old
[0]*DEG2RAD
);
59 new->harmonic
.krA
=old
[1];
60 new->harmonic
.rB
=cos(old
[2]*DEG2RAD
);
61 new->harmonic
.krB
=old
[3];
64 /* Post processing of input data: store square of length itself */
65 new->harmonic
.rA
=sqr(old
[0]);
66 new->harmonic
.krA
=old
[1];
67 new->harmonic
.rB
=sqr(old
[2]);
68 new->harmonic
.krB
=old
[3];
74 new->harmonic
.rA
=old
[0];
75 new->harmonic
.krA
=old
[1];
76 new->harmonic
.rB
=old
[2];
77 new->harmonic
.krB
=old
[3];
80 new->morse
.b0
=old
[0];
81 new->morse
.cb
=old
[1];
82 new->morse
.beta
=old
[2];
85 new->cubic
.b0
=old
[0];
86 new->cubic
.kb
=old
[1];
87 new->cubic
.kcub
=old
[2];
95 new->wpol
.rOH
=old
[3];
96 new->wpol
.rHH
=old
[4];
97 new->wpol
.rOD
=old
[5];
100 new->bham
.a
= old
[0];
101 new->bham
.b
= old
[1];
102 new->bham
.c
= old
[2];
105 new->lj14
.c6A
= old
[0];
106 new->lj14
.c12A
= old
[1];
107 new->lj14
.c6B
= old
[2];
108 new->lj14
.c12B
= old
[3];
112 new->lj
.c12
= old
[1];
117 new->pdihs
.phiA
=old
[0];
118 new->pdihs
.cpA
=old
[1];
119 new->pdihs
.mult
=old
[2];
120 new->pdihs
.phiB
=old
[3];
121 new->pdihs
.cpB
=old
[4];
124 new->posres
.fc
[XX
] = old
[0];
125 new->posres
.fc
[YY
] = old
[1];
126 new->posres
.fc
[ZZ
] = old
[2];
127 new->posres
.pos0
[XX
] = old
[3];
128 new->posres
.pos0
[YY
] = old
[4];
129 new->posres
.pos0
[ZZ
] = old
[5];
132 new->disres
.label
= old
[0];
133 new->disres
.type
= old
[1];
134 new->disres
.low
= old
[2];
135 new->disres
.up1
= old
[3];
136 new->disres
.up2
= old
[4];
137 new->disres
.kfac
= old
[5];
141 fatal_error(0,"Found experiment number for orientation restraints which is smaller than 1 (%d)",old
[0]);
142 new->orires
.ex
= old
[0] - 1;
143 new->orires
.label
= old
[1];
144 new->orires
.power
= old
[2];
145 new->orires
.c
= old
[3];
146 new->orires
.obs
= old
[4];
147 new->orires
.kfac
= old
[5];
150 for (i
=0; (i
<NR_RBDIHS
); i
++) {
151 new->rbdihs
.rbcA
[i
]=old
[i
];
152 new->rbdihs
.rbcB
[i
]=old
[NR_RBDIHS
+i
];
157 new->shake
.dA
= old
[0];
158 new->shake
.dB
= old
[1];
161 new->settle
.doh
=old
[0];
162 new->settle
.dhh
=old
[1];
177 new->dummy
.a
=old
[1] * cos(DEG2RAD
* old
[0]);
178 new->dummy
.b
=old
[1] * sin(DEG2RAD
* old
[0]);
185 fatal_error(0,"unknown function type %d in %s line %d",
186 ftype
,__FILE__
,__LINE__
);
190 static int enter_params(t_idef
*idef
, t_functype ftype
,
191 real forceparams
[MAXFORCEPARAM
],int start
,bool bAppend
)
196 assign_param(ftype
,&new,forceparams
);
198 for (type
=start
; (type
<idef
->ntypes
); type
++) {
199 if (idef
->functype
[type
]==ftype
) {
200 if (memcmp(&new,&idef
->iparams
[type
],(size_t)sizeof(new)) == 0)
208 fprintf(debug
,"copying new to idef->iparams[%d] (ntypes=%d)\n",
210 memcpy(&idef
->iparams
[type
],&new,(size_t)sizeof(new));
213 idef
->functype
[type
]=ftype
;
218 static void append_interaction(t_ilist
*ilist
,
219 int type
,int nral
,atom_id a
[MAXATOMLIST
])
226 ilist
->iatoms
[where1
++]=type
;
227 for (i
=0; (i
<nral
); i
++)
228 ilist
->iatoms
[where1
++]=a
[i
];
231 static void enter_function(t_params
*p
,t_functype ftype
,
232 t_idef
*idef
,int *maxtypes
,bool bNB
,bool bAppend
)
234 int k
,type
,nr
,nral
,delta
,start
;
237 il
= &(idef
->il
[ftype
]);
238 start
= idef
->ntypes
;
242 srenew(il
->iatoms
,il
->nr
+delta
);
244 for (k
=0; k
<nr
; k
++) {
245 if (*maxtypes
<= idef
->ntypes
) {
247 srenew(idef
->functype
,*maxtypes
);
248 srenew(idef
->iparams
, *maxtypes
);
250 fprintf(debug
,"%s, line %d: srenewed idef->functype and idef->iparams to %d\n",
251 __FILE__
,__LINE__
,*maxtypes
);
253 type
= enter_params(idef
,ftype
,p
->param
[k
].c
,start
,bAppend
);
255 append_interaction(il
,type
,nral
,p
->param
[k
].a
);
259 static void new_interaction_list(t_ilist
*ilist
)
264 for(i
=0; (i
<MAXNODES
); i
++)
269 void convert_params(int atnr
,t_params nbtypes
[],
270 t_params plist
[],t_idef
*idef
)
280 idef
->functype
= NULL
;
281 idef
->iparams
= NULL
;
282 for(i
=0; (i
<F_NRE
); i
++) {
284 idef
->il
[i
].iatoms
=NULL
;
286 enter_function(&(nbtypes
[F_LJ
]), (t_functype
)F_LJ
, idef
,
287 &maxtypes
,TRUE
,TRUE
);
288 enter_function(&(nbtypes
[F_BHAM
]),(t_functype
)F_BHAM
,idef
,
289 &maxtypes
,TRUE
,TRUE
);
290 enter_function(&(plist
[F_POSRES
]),(t_functype
)F_POSRES
,idef
,
291 &maxtypes
,FALSE
,TRUE
);
293 for(i
=0; (i
<F_NRE
); i
++) {
294 flags
= interaction_function
[i
].flags
;
295 if ((i
!= F_LJ
) && (i
!= F_BHAM
) && (i
!= F_POSRES
) &&
296 ((flags
& IF_BOND
) || (flags
& IF_DUMMY
) || (flags
& IF_CONSTRAINT
)))
297 enter_function(&(plist
[i
]),(t_functype
)i
,idef
,&maxtypes
,FALSE
,FALSE
);
300 fprintf(debug
,"%s, line %d: There are %d functypes in idef\n",
301 __FILE__
,__LINE__
,idef
->ntypes
);
302 for(j
=0; (j
<F_NRE
); j
++) {
303 for (i
=0; (i
<MAXNODES
); i
++)
304 idef
->il
[j
].multinr
[i
]=idef
->il
[j
].nr
;
306 if (idef
->il
[j
].nr
> 0)
307 printf("# %10s: %d\n",interaction_function
[j
].name
,idef
->il
[j
].nr
);