4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
17 * GROMACS: A message-passing parallel molecular dynamics implementation
18 * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19 * Comp. Phys. Comm. 91, 43-56 (1995)
21 * Also check out our WWW page:
22 * http://md.chem.rug.nl/~gmx
27 * GRowing Old MAkes el Chrono Sweat
29 static char *SRCID_convparm_c
= "$Id$";
44 static void assign_param(t_functype ftype
,t_iparams
*new,
45 real old
[MAXFORCEPARAM
])
50 for(j
=0; (j
<MAXFORCEPARAM
); j
++)
51 new->generic
.buf
[j
]=0.0;
55 /* Post processing of input data: store cosine iso angle itself */
56 new->harmonic
.rA
=cos(old
[0]*DEG2RAD
);
57 new->harmonic
.krA
=old
[1];
58 new->harmonic
.rB
=cos(old
[2]*DEG2RAD
);
59 new->harmonic
.krB
=old
[3];
62 /* Post processing of input data: store square of length itself */
63 new->harmonic
.rA
=sqr(old
[0]);
64 new->harmonic
.krA
=old
[1];
65 new->harmonic
.rB
=sqr(old
[2]);
66 new->harmonic
.krB
=old
[3];
71 new->harmonic
.rA
=old
[0];
72 new->harmonic
.krA
=old
[1];
73 new->harmonic
.rB
=old
[2];
74 new->harmonic
.krB
=old
[3];
77 new->morse
.b0
=old
[0];
78 new->morse
.cb
=old
[1];
79 new->morse
.beta
=old
[2];
85 new->wpol
.rOH
=old
[3];
86 new->wpol
.rHH
=old
[4];
87 new->wpol
.rOD
=old
[5];
95 new->lj14
.c6A
= old
[0];
96 new->lj14
.c12A
= old
[1];
97 new->lj14
.c6B
= old
[2];
98 new->lj14
.c12B
= old
[3];
102 new->lj
.c12
= old
[1];
107 new->pdihs
.phiA
=old
[0];
108 new->pdihs
.cpA
=old
[1];
109 new->pdihs
.mult
=old
[2];
110 new->pdihs
.phiB
=old
[3];
111 new->pdihs
.cpB
=old
[4];
114 new->posres
.fc
[XX
] = old
[0];
115 new->posres
.fc
[YY
] = old
[1];
116 new->posres
.fc
[ZZ
] = old
[2];
117 new->posres
.pos0
[XX
] = old
[3];
118 new->posres
.pos0
[YY
] = old
[4];
119 new->posres
.pos0
[ZZ
] = old
[5];
122 new->disres
.index
=old
[0];
123 new->disres
.type
=old
[1];
124 new->disres
.low
=old
[2];
125 new->disres
.up1
=old
[3];
126 new->disres
.up2
=old
[4];
127 new->disres
.fac
=old
[5];
130 for (i
=0; (i
<NR_RBDIHS
); i
++)
131 new->rbdihs
.rbc
[i
]=old
[i
];
135 new->shake
.dA
= old
[0];
136 new->shake
.dB
= old
[1];
139 new->settle
.doh
=old
[0];
140 new->settle
.dhh
=old
[1];
155 new->dummy
.a
=old
[1] * cos(DEG2RAD
* old
[0]);
156 new->dummy
.b
=old
[1] * sin(DEG2RAD
* old
[0]);
163 fatal_error(0,"unknown function type %d in %s line %d",
164 ftype
,__FILE__
,__LINE__
);
168 static int enter_params(t_idef
*idef
, t_functype ftype
,
169 real forceparams
[MAXFORCEPARAM
],int start
,bool bAppend
)
174 assign_param(ftype
,&new,forceparams
);
176 for (type
=start
; (type
<idef
->ntypes
); type
++) {
177 if (idef
->functype
[type
]==ftype
) {
178 if (memcmp(&new,&idef
->iparams
[type
],(size_t)sizeof(new)) == 0)
186 fprintf(debug
,"copying new to idef->iparams[%d] (ntypes=%d)\n",
188 memcpy(&idef
->iparams
[type
],&new,(size_t)sizeof(new));
191 idef
->functype
[type
]=ftype
;
196 static void append_interaction(t_ilist
*ilist
,
197 int type
,int nral
,atom_id a
[MAXATOMLIST
])
204 ilist
->iatoms
[where1
++]=type
;
205 for (i
=0; (i
<nral
); i
++)
206 ilist
->iatoms
[where1
++]=a
[i
];
209 static void enter_function(t_params
*p
,t_functype ftype
,
210 t_idef
*idef
,int *maxtypes
,bool bNB
,bool bAppend
)
212 int k
,type
,nr
,nral
,delta
,start
;
215 il
= &(idef
->il
[ftype
]);
216 start
= idef
->ntypes
;
220 srenew(il
->iatoms
,il
->nr
+delta
);
222 for (k
=0; k
<nr
; k
++) {
223 if (*maxtypes
<= idef
->ntypes
) {
225 srenew(idef
->functype
,*maxtypes
);
226 srenew(idef
->iparams
, *maxtypes
);
228 fprintf(debug
,"%s, line %d: srenewed idef->functype and idef->iparams to %d\n",
229 __FILE__
,__LINE__
,*maxtypes
);
231 type
= enter_params(idef
,ftype
,p
->param
[k
].c
,start
,bAppend
);
233 append_interaction(il
,type
,nral
,p
->param
[k
].a
);
237 static void new_interaction_list(t_ilist
*ilist
)
242 for(i
=0; (i
<MAXPROC
); i
++)
247 void convert_params(int atnr
,t_params nbtypes
[],
248 t_params plist
[],t_idef
*idef
)
258 idef
->functype
= NULL
;
259 idef
->iparams
= NULL
;
260 for(i
=0; (i
<F_NRE
); i
++) {
262 idef
->il
[i
].iatoms
=NULL
;
264 enter_function(&(nbtypes
[F_LJ
]), (t_functype
)F_LJ
, idef
,
265 &maxtypes
,TRUE
,TRUE
);
266 enter_function(&(nbtypes
[F_BHAM
]),(t_functype
)F_BHAM
,idef
,
267 &maxtypes
,TRUE
,TRUE
);
268 enter_function(&(plist
[F_POSRES
]),(t_functype
)F_POSRES
,idef
,
269 &maxtypes
,FALSE
,TRUE
);
271 for(i
=0; (i
<F_NRE
); i
++) {
272 flags
= interaction_function
[i
].flags
;
273 if ((i
!= F_LJ
) && (i
!= F_BHAM
) && (i
!= F_POSRES
) &&
274 ((flags
& IF_BOND
) || (flags
& IF_DUMMY
) || (flags
& IF_CONSTRAINT
)))
275 enter_function(&(plist
[i
]),(t_functype
)i
,idef
,&maxtypes
,FALSE
,FALSE
);
278 fprintf(debug
,"%s, line %d: There are %d functypes in idef\n",
279 __FILE__
,__LINE__
,idef
->ntypes
);
280 for(j
=0; (j
<F_NRE
); j
++) {
281 for (i
=0; (i
<MAXPROC
); i
++)
282 idef
->il
[j
].multinr
[i
]=idef
->il
[j
].nr
;
284 if (idef
->il
[j
].nr
> 0)
285 printf("# %10s: %d\n",interaction_function
[j
].name
,idef
->il
[j
].nr
);