4 * This source code is part of
8 * 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-2004, 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
60 /* Resource parameters
61 * Do not change any of these until you read the instruction
62 * in readinp.h. Some cpp's do not take spaces after the backslash
63 * (like the c-shell), which will give you a very weird compiler
67 static char tcgrps
[STRLEN
],tau_t
[STRLEN
],ref_t
[STRLEN
],
68 acc
[STRLEN
],accgrps
[STRLEN
],freeze
[STRLEN
],frdim
[STRLEN
],
69 energy
[STRLEN
],user1
[STRLEN
],user2
[STRLEN
],vcm
[STRLEN
],xtc_grps
[STRLEN
],
70 orirefitgrp
[STRLEN
],egexcl
[STRLEN
];
71 static char anneal
[STRLEN
],anneal_npoints
[STRLEN
],
72 anneal_time
[STRLEN
],anneal_temp
[STRLEN
];
73 static char efield_x
[STRLEN
],efield_xt
[STRLEN
],efield_y
[STRLEN
],
74 efield_yt
[STRLEN
],efield_z
[STRLEN
],efield_zt
[STRLEN
];
76 void init_ir(t_inputrec
*ir
, t_gromppopts
*opts
)
78 snew(opts
->title
,STRLEN
);
79 snew(opts
->cpp
,STRLEN
);
80 snew(opts
->include
,STRLEN
);
81 snew(opts
->define
,STRLEN
);
82 snew(opts
->SolventOpt
,STRLEN
);
85 static void _low_check(bool b
,char *s
,int *n
)
88 fprintf(stderr
,"ERROR: %s\n",s
);
93 void check_ir(t_inputrec
*ir
, t_gromppopts
*opts
,int *nerror
)
94 /* Check internal consistency */
96 /* Strange macro: first one fills the err_buf, and then one can check
97 * the condition, which will print the message and increase the error
100 #define CHECK(b) _low_check(b,err_buf,nerror)
104 sprintf(err_buf
,"constraints with Conjugate Gradients not implemented");
105 CHECK((opts
->nshake
> 0) && (ir
->eI
== eiCG
));
107 if ( (opts
->nshake
> 0) && (opts
->bMorse
) ) {
109 "Using morse bond-potentials while constraining bonds is useless");
113 sprintf(err_buf
,"shake_tol must be > 0 instead of %g while using shake",
115 CHECK(((ir
->shake_tol
<= 0.0) && (opts
->nshake
>0) &&
116 (ir
->eConstrAlg
== estSHAKE
)));
120 if (ir
->ePBC
== epbcNONE
) {
121 if (ir
->epc
!= epcNO
) {
122 warning("Turning off pressure coupling for vacuum system");
126 if (ir
->ns_type
!= ensSIMPLE
) {
127 sprintf(warn_buf
,"Can only use nstype=%s with pbc=%s, setting nstype "
129 ens_names
[ensSIMPLE
],epbc_names
[epbcNONE
],ens_names
[ensSIMPLE
]);
131 ir
->ns_type
= ensSIMPLE
;
133 if (ir
->eDispCorr
!= edispcNO
) {
134 warning("Can not have long-range dispersion correction without PBC,"
136 ir
->eDispCorr
= edispcNO
;
140 if (ir
->rlist
== 0.0) {
141 sprintf(err_buf
,"can only have neighborlist cut-off zero (=infinite)\n"
142 "with coulombtype = %s or coulombtype = %s"
143 "and simple neighborsearch\n"
144 "without periodic boundary conditions (pbc = %s) and\n"
145 "rcoulomb and rvdw set to zero",
146 eel_names
[eelCUT
],eel_names
[eelUSER
],epbc_names
[epbcNONE
]);
147 CHECK(((ir
->coulombtype
!= eelCUT
) && (ir
->coulombtype
!= eelUSER
))
148 || (ir
->ns_type
!= ensSIMPLE
) ||
149 (ir
->ePBC
!= epbcNONE
) ||
150 (ir
->rcoulomb
!= 0.0) || (ir
->rvdw
!= 0.0));
154 if ((ir
->ePBC
!= epbcNONE
) && (ir
->nstcomm
< 0))
155 warning("Removing the rotation around the center of mass in a periodic system (this is not a problem when you have only one molecule).");
157 if ((ir
->eI
== eiMD
) && (ir
->ePBC
== epbcNONE
)) {
159 warning("Tumbling ice-cubes: We are not removing rotation around center of mass in a non-periodic system. You should set nstcomm = -1.");
160 if (ir
->nstcomm
== 0)
161 warning("Flying ice-cubes: We are not removing center of mass motion in a non-periodic system. You should set nstcomm = -1 (will also stop rotation).");
164 if ((EEL_LR(ir
->coulombtype
)) && (ir
->efep
!=efepNO
)) {
165 warning("You are using lattice sum electrostatics with free energy integration. "
166 "This might give wrong results, since the lattice contribution "
167 "to the free energy not calculated.");
170 sprintf(err_buf
,"Domain decomposition can only be used with grid NS");
171 CHECK(ir
->bDomDecomp
&& (ir
->ns_type
== ensSIMPLE
));
172 sprintf(err_buf
,"Twin-range neighbour searching (NS) with simple NS"
173 " algorithm not implemented");
174 CHECK(((ir
->rcoulomb
> ir
->rlist
) || (ir
->rvdw
> ir
->rlist
))
175 && (ir
->ns_type
== ensSIMPLE
));
177 /* PRESSURE COUPLING */
178 if(ir
->epc
== epcISOTROPIC
) {
179 ir
->epc
= epcBERENDSEN
;
180 fprintf(stderr
,"Note: Old option for pressure coupling given: "
181 "changing \"Isotropic\" to \"Berendsen\"\n");
184 if (ir
->epc
!= epcNO
) {
185 sprintf(err_buf
,"tau_p must be > 0 instead of %g\n",ir
->tau_p
);
186 CHECK(ir
->tau_p
<= 0);
188 sprintf(err_buf
,"compressibility must be > 0 when using pressure"
189 " coupling %s\n",EPCOUPLTYPE(ir
->epc
));
190 CHECK(ir
->compress
[XX
][XX
] < 0 || ir
->compress
[YY
][YY
] < 0 ||
191 ir
->compress
[ZZ
][ZZ
] < 0 || trace(ir
->compress
) == 0);
193 sprintf(err_buf
,"pressure coupling with PPPM not implemented, use PME");
194 CHECK(ir
->coulombtype
== eelPPPM
);
196 } else if (ir
->coulombtype
== eelPPPM
) {
197 sprintf(warn_buf
,"The pressure with PPPM is incorrect, if you need the pressure use PME");
201 /* TEMPERATURE COUPLING */
202 if(ir
->etc
== etcYES
) {
203 ir
->etc
= etcBERENDSEN
;
204 fprintf(stderr
,"Note: Old option for temperature coupling given: "
205 "changing \"yes\" to \"Berendsen\"\n");
208 if((ir
->etc
==etcNOSEHOOVER
|| ir
->etc
==etcANDERSEN
|| ir
->etc
==etcANDERSENINTERVAL
)
209 && ir
->epc
==epcBERENDSEN
) {
210 sprintf(warn_buf
,"Using Berendsen pressure coupling invalidates the "
211 "true ensemble for the thermostat");
216 /* More checks are in triple check (grompp.c) */
217 sprintf(err_buf
,"epsilon_r must be >= 0 instead of %g\n",ir
->epsilon_r
);
218 CHECK(ir
->epsilon_r
< 0);
220 if (ir
->epsilon_r
== 0) {
221 sprintf(err_buf
,"epsilon_r can only be %f (=infinity) with (generalized)"
222 " reaction field",ir
->epsilon_r
);
223 CHECK((ir
->coulombtype
!= eelRF
) && (ir
->coulombtype
!= eelGRF
));
226 if ((ir
->coulombtype
== eelRF
) || (ir
->coulombtype
== eelGRF
)) {
227 /* reaction field (at the cut-off) */
228 if (ir
->epsilon_r
== 1.0) {
229 sprintf(warn_buf
,"Using epsilon_r = 1.0 with %s does not make sense",
230 eel_names
[ir
->coulombtype
]);
234 if (EEL_LR(ir
->coulombtype
)) {
235 sprintf(err_buf
,"With coulombtype = %s rcoulomb must be == rlist",
236 eel_names
[ir
->coulombtype
]);
237 CHECK(ir
->rcoulomb
!= ir
->rlist
);
238 } else if ((ir
->coulombtype
== eelSHIFT
) || (ir
->coulombtype
== eelSWITCH
)) {
239 sprintf(err_buf
,"With coulombtype = %s rcoulomb_switch must be < rcoulomb",
240 eel_names
[ir
->coulombtype
]);
241 CHECK(ir
->rcoulomb_switch
>= ir
->rcoulomb
);
242 if (ir
->rcoulomb_switch
> ir
->rcoulomb
-0.0999) {
243 sprintf(warn_buf
,"rcoulomb should be 0.1 to 0.3 nm larger than rcoulomb_switch to account for diffusion and the size of charge groups");
247 sprintf(err_buf
,"rcoulomb must be >= rlist");
248 CHECK(ir
->rlist
> ir
->rcoulomb
);
251 if (ir
->coulombtype
== eelPME
) {
252 if ((ir
->pme_order
< 4) || ((ir
->pme_order
% 2) == 1)) {
253 if (ir
->pme_order
< 4)
255 else if ((ir
->pme_order
% 2) == 1)
257 sprintf(err_buf
,"pme_order should be even and at least 4, modified to %d",
263 if ((ir
->vdwtype
== evdwSWITCH
) || (ir
->vdwtype
== evdwSHIFT
)) {
264 sprintf(err_buf
,"With vdwtype = %s rvdw_switch must be < rvdw",
265 evdw_names
[ir
->vdwtype
]);
266 CHECK(ir
->rvdw_switch
>= ir
->rvdw
);
267 if (ir
->rvdw_switch
> ir
->rvdw
-0.0999) {
268 sprintf(warn_buf
,"rvdw should be 0.1 to 0.3 nm larger than rvdw_switch to account for diffusion and the size of charge groups");
272 sprintf(err_buf
,"rvdw must be >= rlist");
273 CHECK(ir
->rlist
> ir
->rvdw
);
275 if((ir
->coulombtype
== eelSHIFT
) || (ir
->coulombtype
== eelSWITCH
) ||
276 (ir
->vdwtype
== evdwSWITCH
) || (ir
->vdwtype
== evdwSHIFT
))
277 if((ir
->rlist
== ir
->rcoulomb
) || (ir
->rlist
== ir
->rvdw
)) {
278 sprintf(warn_buf
,"For energy conservation with switch/shift potentials, rlist should be 0.1 to 0.3 nm larger than rcoulomb/rvdw.");
283 if(ir
->eI
==eiMD
&& ir
->etc
==etcNO
&&
284 ir
->eConstrAlg
==estLINCS
&& ir
->nLincsIter
==1) {
285 sprintf(warn_buf
,"For energy conservation with LINCS, lincs_iter should be 2 or larger.\n"
286 "You can safely ignore this if your system doesn't have any LINCS-constrained bonds;\n"
287 "for water molecules we normally use the analytical SETTLE algorithm instead.");
290 if(((ir
->eI
== eiSteep
) || (ir
->eI
== eiCG
)) && (ir
->nLincsIter
<4)) {
291 sprintf(warn_buf
,"For energy minimization with constraints, lincs_iter should be 4 to 8.");
296 static int str_nelem(char *str
,int maxptr
,char *ptr
[])
304 while (*copy
!= '\0') {
306 fatal_error(0,"Too many groups on line: '%s' (max is %d)",
311 while ((*copy
!= '\0') && !isspace(*copy
))
326 void get_ir(char *mdparin
,char *mdparout
,
327 t_inputrec
*ir
,t_gromppopts
*opts
,int *nerror
)
334 int i
,m
,ninp
,ecm_mode
;
338 inp
=read_inpfile(mdparin
,&ninp
);
340 snew(dumstr
[0],STRLEN
);
341 snew(dumstr
[1],STRLEN
);
343 CCTYPE ("VARIOUS PREPROCESSING OPTIONS");
344 STYPE ("title", opts
->title
, NULL
);
345 STYPE ("cpp", opts
->cpp
, "/lib/cpp");
346 STYPE ("include", opts
->include
, NULL
);
347 STYPE ("define", opts
->define
, NULL
);
349 CCTYPE ("RUN CONTROL PARAMETERS");
350 EETYPE("integrator", ir
->eI
, ei_names
, nerror
, TRUE
);
351 CTYPE ("Start time and timestep in ps");
352 RTYPE ("tinit", ir
->init_t
, 0.0);
353 RTYPE ("dt", ir
->delta_t
, 0.001);
354 ITYPE ("nsteps", ir
->nsteps
, 0);
355 CTYPE ("For exact run continuation or redoing part of a run");
356 ITYPE ("init_step", ir
->init_step
, 0);
357 CTYPE ("mode for center of mass motion removal");
358 EETYPE("comm-mode", ecm_mode
, ecm_names
, nerror
, TRUE
);
359 CTYPE ("number of steps for center of mass motion removal");
360 ITYPE ("nstcomm", ir
->nstcomm
, 1);
361 CTYPE ("group(s) for center of mass motion removal");
362 STYPE ("comm-grps", vcm
, NULL
);
364 CCTYPE ("LANGEVIN DYNAMICS OPTIONS");
365 CTYPE ("Temperature, friction coefficient (amu/ps) and random seed");
366 RTYPE ("bd-temp", ir
->bd_temp
, 300.0);
367 RTYPE ("bd-fric", ir
->bd_fric
, 0.0);
368 ITYPE ("ld-seed", ir
->ld_seed
, 1993);
371 CCTYPE ("ENERGY MINIMIZATION OPTIONS");
372 CTYPE ("Force tolerance and initial step-size");
373 RTYPE ("emtol", ir
->em_tol
, 100.0);
374 RTYPE ("emstep", ir
->em_stepsize
,0.01);
375 CTYPE ("Max number of iterations in relax_shells");
376 ITYPE ("niter", ir
->niter
, 20);
377 CTYPE ("Step size (1/ps^2) for minimization of flexible constraints");
378 ITYPE ("fcstep", ir
->fc_stepsize
, 0);
379 CTYPE ("Frequency of steepest descents steps when doing CG");
380 ITYPE ("nstcgsteep", ir
->nstcgsteep
, 1000);
383 CCTYPE ("OUTPUT CONTROL OPTIONS");
384 CTYPE ("Output frequency for coords (x), velocities (v) and forces (f)");
385 ITYPE ("nstxout", ir
->nstxout
, 100);
386 ITYPE ("nstvout", ir
->nstvout
, 100);
387 ITYPE ("nstfout", ir
->nstfout
, 0);
388 CTYPE ("Checkpointing helps you continue after crashes");
389 ITYPE ("nstcheckpoint", ir
->nstcheckpoint
, 1000);
390 CTYPE ("Output frequency for energies to log file and energy file");
391 ITYPE ("nstlog", ir
->nstlog
, 100);
392 ITYPE ("nstenergy", ir
->nstenergy
, 100);
393 CTYPE ("Output frequency and precision for xtc file");
394 ITYPE ("nstxtcout", ir
->nstxtcout
, 0);
395 RTYPE ("xtc-precision",ir
->xtcprec
, 1000.0);
396 CTYPE ("This selects the subset of atoms for the xtc file. You can");
397 CTYPE ("select multiple groups. By default all atoms will be written.");
398 STYPE ("xtc-grps", xtc_grps
, NULL
);
399 CTYPE ("Selection of energy groups");
400 STYPE ("energygrps", energy
, NULL
);
402 /* Neighbor searching */
403 CCTYPE ("NEIGHBORSEARCHING PARAMETERS");
404 CTYPE ("nblist update frequency");
405 ITYPE ("nstlist", ir
->nstlist
, 10);
406 CTYPE ("ns algorithm (simple or grid)");
407 EETYPE("ns-type", ir
->ns_type
, ens_names
, nerror
, TRUE
);
408 /* set ndelta to the optimal value of 2 */
410 CTYPE ("Periodic boundary conditions: xyz (default), no (vacuum)");
411 CTYPE ("or full (infinite systems only)");
412 EETYPE("pbc", ir
->ePBC
, epbc_names
, nerror
, TRUE
);
413 CTYPE ("nblist cut-off");
414 RTYPE ("rlist", ir
->rlist
, 1.0);
415 EETYPE("domain-decomposition",ir
->bDomDecomp
, yesno_names
, nerror
, TRUE
);
418 CCTYPE ("OPTIONS FOR ELECTROSTATICS AND VDW");
419 CTYPE ("Method for doing electrostatics");
420 EETYPE("coulombtype", ir
->coulombtype
, eel_names
, nerror
, TRUE
);
421 CTYPE ("cut-off lengths");
422 RTYPE ("rcoulomb-switch", ir
->rcoulomb_switch
, 0.0);
423 RTYPE ("rcoulomb", ir
->rcoulomb
, 1.0);
424 CTYPE ("Dielectric constant (DC) for cut-off or DC of reaction field");
425 STYPE ("epsilon-r", epsbuf
, "1");
426 CTYPE ("Method for doing Van der Waals");
427 EETYPE("vdw-type", ir
->vdwtype
, evdw_names
, nerror
, TRUE
);
428 CTYPE ("cut-off lengths");
429 RTYPE ("rvdw-switch", ir
->rvdw_switch
, 0.0);
430 RTYPE ("rvdw", ir
->rvdw
, 1.0);
431 CTYPE ("Apply long range dispersion corrections for Energy and Pressure");
432 EETYPE("DispCorr", ir
->eDispCorr
, edispc_names
, nerror
, TRUE
);
433 CTYPE ("Extension of the potential lookup tables beyond the cut-off");
434 RTYPE ("table-extension", ir
->tabext
, 1.0);
435 CTYPE ("Spacing for the PME/PPPM FFT grid");
436 RTYPE ("fourierspacing", opts
->fourierspacing
,0.12);
437 CTYPE ("FFT grid size, when a value is 0 fourierspacing will be used");
438 ITYPE ("fourier_nx", ir
->nkx
, 0);
439 ITYPE ("fourier_ny", ir
->nky
, 0);
440 ITYPE ("fourier_nz", ir
->nkz
, 0);
441 CTYPE ("EWALD/PME/PPPM parameters");
442 ITYPE ("pme_order", ir
->pme_order
, 4);
443 RTYPE ("ewald_rtol", ir
->ewald_rtol
, 0.00001);
444 EETYPE("ewald_geometry", ir
->ewald_geometry
, eewg_names
, nerror
, TRUE
);
445 RTYPE ("epsilon_surface", ir
->epsilon_surface
, 0.0);
446 EETYPE("optimize_fft",ir
->bOptFFT
, yesno_names
, nerror
, TRUE
);
448 CCTYPE ("GENERALIZED BORN ELECTROSTATICS");
449 CTYPE ("Algorithm for calculating Born radii");
450 EETYPE("gb_algorithm", ir
->gb_algorithm
, egb_names
, nerror
, TRUE
);
451 CTYPE ("Frequency of calculating the Born radii inside rlist");
452 ITYPE ("nstgbradii", ir
->nstgbradii
, 1);
453 CTYPE ("Cutoff for Born radii calculation; the contribution from atoms");
454 CTYPE ("between rlist and rgbradii is updated every nstlist steps");
455 RTYPE ("rgbradii", ir
->rgbradii
, 2.0);
456 CTYPE ("Salt concentration in M for Generalized Born models");
457 RTYPE ("gb_saltconc", ir
->gb_saltconc
, 0.0);
459 CCTYPE("IMPLICIT SOLVENT (for use with Generalized Born electrostatics)");
460 EETYPE("implicit_solvent", ir
->implicit_solvent
, eis_names
, nerror
, TRUE
);
463 CCTYPE ("OPTIONS FOR WEAK COUPLING ALGORITHMS");
464 CTYPE ("Temperature coupling");
465 EETYPE("tcoupl", ir
->etc
, etcoupl_names
, nerror
, TRUE
);
466 CTYPE ("Groups to couple separately");
467 STYPE ("tc-grps", tcgrps
, NULL
);
468 CTYPE ("Time constant (ps) and reference temperature (K)");
469 STYPE ("tau-t", tau_t
, NULL
);
470 STYPE ("ref-t", ref_t
, NULL
);
471 CTYPE ("Pressure coupling");
472 EETYPE("Pcoupl", ir
->epc
, epcoupl_names
, nerror
, TRUE
);
473 EETYPE("Pcoupltype", ir
->epct
, epcoupltype_names
, nerror
, TRUE
);
474 CTYPE ("Time constant (ps), compressibility (1/bar) and reference P (bar)");
475 RTYPE ("tau-p", ir
->tau_p
, 1.0);
476 STYPE ("compressibility", dumstr
[0], NULL
);
477 STYPE ("ref-p", dumstr
[1], NULL
);
479 CTYPE ("Random seed for Andersen thermostat");
480 ITYPE ("andersen_seed", ir
->andersen_seed
, 815131);
482 /* Simulated annealing */
483 CCTYPE("SIMULATED ANNEALING");
484 CTYPE ("Type of annealing for each temperature group (no/single/periodic)");
485 STYPE ("annealing", anneal
, NULL
);
486 CTYPE ("Number of time points to use for specifying annealing in each group");
487 STYPE ("annealing_npoints", anneal_npoints
, NULL
);
488 CTYPE ("List of times at the annealing points for each group");
489 STYPE ("annealing_time", anneal_time
, NULL
);
490 CTYPE ("Temp. at each annealing point, for each group.");
491 STYPE ("annealing_temp", anneal_temp
, NULL
);
494 CCTYPE ("GENERATE VELOCITIES FOR STARTUP RUN");
495 EETYPE("gen-vel", opts
->bGenVel
, yesno_names
, nerror
, TRUE
);
496 RTYPE ("gen-temp", opts
->tempi
, 300.0);
497 ITYPE ("gen-seed", opts
->seed
, 173529);
500 CCTYPE ("OPTIONS FOR BONDS");
501 EETYPE("constraints", opts
->nshake
, constraints
, nerror
, TRUE
);
502 CTYPE ("Type of constraint algorithm");
503 EETYPE("constraint-algorithm", ir
->eConstrAlg
, eshake_names
, nerror
, TRUE
);
504 CTYPE ("Do not constrain the start configuration");
505 EETYPE("unconstrained-start", ir
->bUncStart
, yesno_names
, nerror
, TRUE
);
506 CTYPE ("Use successive overrelaxation to reduce the number of shake iterations");
507 EETYPE("Shake-SOR", ir
->bShakeSOR
, yesno_names
, nerror
, TRUE
);
508 CTYPE ("Relative tolerance of shake");
509 RTYPE ("shake-tol", ir
->shake_tol
, 0.0001);
510 CTYPE ("Highest order in the expansion of the constraint coupling matrix");
511 ITYPE ("lincs-order", ir
->nProjOrder
, 4);
512 CTYPE ("Number of iterations in the final step of LINCS. 1 is fine for");
513 CTYPE ("normal simulations, but use 2 to conserve energy in NVE runs.");
514 CTYPE ("For energy minimization with constraints it should be 4 to 8.");
515 ITYPE ("lincs-iter", ir
->nLincsIter
, 1);
516 CTYPE ("Lincs will write a warning to the stderr if in one step a bond");
517 CTYPE ("rotates over more degrees than");
518 RTYPE ("lincs-warnangle", ir
->LincsWarnAngle
, 30.0);
519 CTYPE ("Convert harmonic bonds to morse potentials");
520 EETYPE("morse", opts
->bMorse
,yesno_names
, nerror
, TRUE
);
522 /* Energy group exclusions */
523 CCTYPE ("ENERGY GROUP EXCLUSIONS");
524 CTYPE ("Pairs of energy groups for which all non-bonded interactions are excluded");
525 STYPE ("energygrp_excl", egexcl
, NULL
);
528 CCTYPE("NMR refinement stuff");
529 CTYPE ("Distance restraints type: No, Simple or Ensemble");
530 EETYPE("disre", opts
->eDisre
, edisre_names
, nerror
, TRUE
);
531 CTYPE ("Force weighting of pairs in one distance restraint: Conservative or Equal");
532 EETYPE("disre-weighting", ir
->eDisreWeighting
, edisreweighting_names
, nerror
, TRUE
);
533 CTYPE ("Use sqrt of the time averaged times the instantaneous violation");
534 EETYPE("disre-mixed", ir
->bDisreMixed
, yesno_names
, nerror
, TRUE
);
535 RTYPE ("disre-fc", ir
->dr_fc
, 1000.0);
536 RTYPE ("disre-tau", ir
->dr_tau
, 0.0);
537 CTYPE ("Output frequency for pair distances to energy file");
538 ITYPE ("nstdisreout", ir
->nstdisreout
, 100);
539 CTYPE ("Orientation restraints: No or Yes");
540 EETYPE("orire", opts
->bOrire
, yesno_names
, nerror
, TRUE
);
541 CTYPE ("Orientation restraints force constant and tau for time averaging");
542 RTYPE ("orire-fc", ir
->orires_fc
, 0.0);
543 RTYPE ("orire-tau", ir
->orires_tau
, 0.0);
544 STYPE ("orire-fitgrp",orirefitgrp
, NULL
);
545 CTYPE ("Output frequency for trace(SD) to energy file");
546 ITYPE ("nstorireout", ir
->nstorireout
, 100);
547 CTYPE ("Dihedral angle restraints: No, Simple or Ensemble");
548 EETYPE("dihre", opts
->eDihre
, edisre_names
, nerror
, TRUE
);
549 RTYPE ("dihre-fc", ir
->dihre_fc
, 1000.0);
550 RTYPE ("dihre-tau", ir
->dihre_tau
, 0.0);
551 CTYPE ("Output frequency for dihedral values to energy file");
552 ITYPE ("nstdihreout", ir
->nstdihreout
, 100);
554 /* Free energy stuff */
555 CCTYPE ("Free energy control stuff");
556 EETYPE("free-energy", ir
->efep
, efep_names
, nerror
, TRUE
);
557 RTYPE ("init-lambda", ir
->init_lambda
,0.0);
558 RTYPE ("delta-lambda",ir
->delta_lambda
,0.0);
559 RTYPE ("sc-alpha",ir
->sc_alpha
,0.0);
560 RTYPE ("sc-sigma",ir
->sc_sigma
,0.3);
562 /* Non-equilibrium MD stuff */
563 CCTYPE("Non-equilibrium MD stuff");
564 STYPE ("acc-grps", accgrps
, NULL
);
565 STYPE ("accelerate", acc
, NULL
);
566 STYPE ("freezegrps", freeze
, NULL
);
567 STYPE ("freezedim", frdim
, NULL
);
568 RTYPE ("cos-acceleration", ir
->cos_accel
, 0);
570 /* Electric fields */
571 CCTYPE("Electric fields");
572 CTYPE ("Format is number of terms (int) and for all terms an amplitude (real)");
573 CTYPE ("and a phase angle (real)");
574 STYPE ("E-x", efield_x
, NULL
);
575 STYPE ("E-xt", efield_xt
, NULL
);
576 STYPE ("E-y", efield_y
, NULL
);
577 STYPE ("E-yt", efield_yt
, NULL
);
578 STYPE ("E-z", efield_z
, NULL
);
579 STYPE ("E-zt", efield_zt
, NULL
);
581 /* User defined thingies */
582 CCTYPE ("User defined thingies");
583 STYPE ("user1-grps", user1
, NULL
);
584 STYPE ("user2-grps", user2
, NULL
);
585 ITYPE ("userint1", ir
->userint1
, 0);
586 ITYPE ("userint2", ir
->userint2
, 0);
587 ITYPE ("userint3", ir
->userint3
, 0);
588 ITYPE ("userint4", ir
->userint4
, 0);
589 RTYPE ("userreal1", ir
->userreal1
, 0);
590 RTYPE ("userreal2", ir
->userreal2
, 0);
591 RTYPE ("userreal3", ir
->userreal3
, 0);
592 RTYPE ("userreal4", ir
->userreal4
, 0);
595 write_inpfile(mdparout
,ninp
,inp
);
596 for (i
=0; (i
<ninp
); i
++) {
602 /* Process options if necessary */
603 /* Convert to uppercase and trim the epsilon_r string buffer */
606 if (strlen(epsbuf
) == 0)
609 if (strstr(epsbuf
,"INF") != NULL
)
611 else if (sscanf(epsbuf
,"%lf",&epsje
) == 1)
612 ir
->epsilon_r
= epsje
;
614 sprintf(warn_buf
,"Invalid value for epsilon_r: %s, setting to 1",epsbuf
);
620 for(i
=0; i
<2*DIM
; i
++)
625 if (sscanf(dumstr
[m
],"%lf",&(dumdub
[m
][XX
]))!=1) {
627 "ERROR: pressure coupling not enough values (I need 1)\n");
630 dumdub
[m
][YY
]=dumdub
[m
][ZZ
]=dumdub
[m
][XX
];
632 case epctSEMIISOTROPIC
:
633 case epctSURFACETENSION
:
634 if (sscanf(dumstr
[m
],"%lf%lf",
635 &(dumdub
[m
][XX
]),&(dumdub
[m
][ZZ
]))!=2) {
637 "ERROR: pressure coupling not enough values (I need 2)\n");
640 dumdub
[m
][YY
]=dumdub
[m
][XX
];
642 case epctANISOTROPIC
:
643 if (sscanf(dumstr
[m
],"%lf%lf%lf%lf%lf%lf",
644 &(dumdub
[m
][XX
]),&(dumdub
[m
][YY
]),&(dumdub
[m
][ZZ
]),
645 &(dumdub
[m
][3]),&(dumdub
[m
][4]),&(dumdub
[m
][5]))!=6) {
647 "ERROR: pressure coupling not enough values (I need 6)\n");
652 fatal_error(0,"Pressure coupling type %s not implemented yet",
653 epcoupltype_names
[ir
->epct
]);
657 clear_mat(ir
->ref_p
);
658 clear_mat(ir
->compress
);
659 for(i
=0; i
<DIM
; i
++) {
660 ir
->ref_p
[i
][i
] = dumdub
[1][i
];
661 ir
->compress
[i
][i
] = dumdub
[0][i
];
663 if (ir
->epct
== epctANISOTROPIC
) {
664 ir
->ref_p
[XX
][YY
] = dumdub
[1][3];
665 ir
->ref_p
[XX
][ZZ
] = dumdub
[1][4];
666 ir
->ref_p
[YY
][ZZ
] = dumdub
[1][5];
667 ir
->compress
[XX
][YY
] = dumdub
[0][3];
668 ir
->compress
[XX
][ZZ
] = dumdub
[0][4];
669 ir
->compress
[YY
][ZZ
] = dumdub
[0][5];
672 ir
->ref_p
[i
][m
] = ir
->ref_p
[m
][i
];
673 ir
->compress
[i
][m
] = ir
->compress
[m
][i
];
682 sprintf(warn_buf
,"mdrun will apply removal of angular momentum when nstcomm < 0");
688 ir
->nstcomm
= -ir
->nstcomm
;
692 if (opts
->bOrire
&& str_nelem(orirefitgrp
,MAXPTR
,NULL
)!=1) {
693 fprintf(stderr
,"ERROR: Need one orientation restraint fit group\n");
702 static int search_string(char *s
,int ng
,char *gn
[])
706 for(i
=0; (i
<ng
); i
++)
707 if (strcasecmp(s
,gn
[i
]) == 0)
710 fatal_error(0,"Group %s not found in indexfile.\nMaybe you have non-default goups in your mdp file, while not using the '-n' option of grompp.\nIn that case use the '-n' option.\n",s
);
715 static void do_numbering(t_atoms
*atoms
,int ng
,char *ptrs
[],
716 t_block
*block
,char *gnames
[],
717 int gtype
,int restnm
,
718 int *forward
,bool bOneGroup
,bool bVerbose
)
720 unsigned short *cbuf
;
721 t_grps
*groups
=&(atoms
->grps
[gtype
]);
722 int i
,j
,gid
,aj
,ognr
,ntot
=0;
726 fprintf(debug
,"Starting numbering %d groups of type %d\n",ng
,gtype
);
728 title
= gtypes
[gtype
];
730 snew(cbuf
,atoms
->nr
);
731 for(i
=0; (i
<atoms
->nr
); i
++)
734 snew(groups
->nm_ind
,ng
+1); /* +1 for possible rest group */
735 for(i
=0; (i
<ng
); i
++) {
736 /* Lookup the group name in the block structure */
737 gid
= search_string(ptrs
[i
],block
->nr
,gnames
);
738 if ((i
==0) || !bOneGroup
)
739 groups
->nm_ind
[groups
->nr
++]=gid
;
741 fprintf(debug
,"Found gid %d for group %s\n",gid
,ptrs
[i
]);
743 /* Now go over the atoms in the group */
744 for(j
=block
->index
[gid
]; (j
<block
->index
[gid
+1]); j
++) {
748 if ((aj
< 0) || (aj
>= atoms
->nr
))
749 fatal_error(0,"Invalid atom number %d in indexfile",aj
);
751 /* Lookup up the old group number */
754 fatal_error(0,"Atom %d in multiple %s groups (%d and %d)",
757 /* Store the group number in buffer */
767 /* Now check whether we have done all atoms */
768 if (ntot
!= atoms
->nr
) {
770 fprintf(stderr
,"Making dummy/rest group for %s containing %d elements\n",
771 title
,atoms
->nr
-ntot
);
772 /* Add group name "rest" */
773 groups
->nm_ind
[groups
->nr
] = restnm
;
775 /* Assign the rest name to all atoms not currently assigned to a group */
776 for(j
=0; (j
<atoms
->nr
); j
++) {
777 if (cbuf
[j
] == NOGID
)
778 cbuf
[j
] = groups
->nr
;
782 if (forward
!= NULL
) {
783 for(j
=0; (j
<atoms
->nr
); j
++)
784 atoms
->atom
[j
].grpnr
[gtype
]=cbuf
[forward
[j
]];
787 for(j
=0; (j
<atoms
->nr
); j
++)
788 atoms
->atom
[j
].grpnr
[gtype
]=cbuf
[j
];
793 static void calc_nrdf(t_atoms
*atoms
,t_idef
*idef
,t_grpopts
*opts
,
794 char **gnames
,int nstcomm
)
796 int ai
,aj
,i
,j
,d
,g
,imin
,jmin
;
798 int *nrdf
,*na_vcm
,na_tot
;
799 double *nrdf_vcm
,nrdf_uc
,n_sub
;
802 * First calc 3xnr-atoms for each group
803 * then subtract half a degree of freedom for each constraint
805 * Only atoms and nuclei contribute to the degrees of freedom...
808 snew(nrdf_vcm
,atoms
->grps
[egcVCM
].nr
);
809 snew(na_vcm
,atoms
->grps
[egcVCM
].nr
);
811 for(i
=0; i
<atoms
->grps
[egcTC
].nr
; i
++)
813 for(i
=0; i
<atoms
->grps
[egcVCM
].nr
; i
++)
816 snew(nrdf
,atoms
->nr
);
817 for(i
=0; i
<atoms
->nr
; i
++) {
819 if ((atoms
->atom
[i
].ptype
== eptAtom
) ||
820 (atoms
->atom
[i
].ptype
== eptNucleus
)) {
821 g
= atoms
->atom
[i
].grpnr
[egcFREEZE
];
822 /* Double count nrdf for particle i */
824 if (opts
->nFreeze
[g
][d
] == 0)
826 opts
->nrdf
[atoms
->atom
[i
].grpnr
[egcTC
]] += 0.5*nrdf
[i
];
827 nrdf_vcm
[atoms
->atom
[i
].grpnr
[egcVCM
]] += 0.5*nrdf
[i
];
830 ia
=idef
->il
[F_SHAKE
].iatoms
;
831 for(i
=0; (i
<idef
->il
[F_SHAKE
].nr
); ) {
832 /* Subtract degrees of freedom for the constraints,
833 * if the particles still have degrees of freedom left.
834 * If one of the particles is a dummy or a shell, then all
835 * constraints motion will go there, but since they do not
836 * contribute to the constraints the degrees of freedom do not
841 if (((atoms
->atom
[ai
].ptype
== eptNucleus
) ||
842 (atoms
->atom
[ai
].ptype
== eptAtom
)) &&
843 ((atoms
->atom
[aj
].ptype
== eptNucleus
) ||
844 (atoms
->atom
[aj
].ptype
== eptAtom
))) {
853 imin
= min(imin
,nrdf
[ai
]);
854 jmin
= min(jmin
,nrdf
[aj
]);
857 opts
->nrdf
[atoms
->atom
[ai
].grpnr
[egcTC
]] -= 0.5*imin
;
858 opts
->nrdf
[atoms
->atom
[aj
].grpnr
[egcTC
]] -= 0.5*jmin
;
859 nrdf_vcm
[atoms
->atom
[ai
].grpnr
[egcVCM
]] -= 0.5*imin
;
860 nrdf_vcm
[atoms
->atom
[aj
].grpnr
[egcVCM
]] -= 0.5*jmin
;
862 ia
+= interaction_function
[F_SHAKE
].nratoms
+1;
863 i
+= interaction_function
[F_SHAKE
].nratoms
+1;
865 ia
=idef
->il
[F_SETTLE
].iatoms
;
866 for(i
=0; i
<idef
->il
[F_SETTLE
].nr
; ) {
867 for(ai
=ia
[1]; ai
<ia
[1]+3; ai
++) {
868 opts
->nrdf
[atoms
->atom
[ai
].grpnr
[egcTC
]] -= 1;
869 nrdf_vcm
[atoms
->atom
[ai
].grpnr
[egcVCM
]] -= 1;
876 /* Subtract 3 from the number of degrees of freedom in each vcm group
877 * when com translation is removed and 6 when rotation is removed
889 for(i
=0; i
<atoms
->grps
[egcTC
].nr
; i
++) {
890 /* Count the number of atoms of TC group i for every VCM group */
891 for(j
=0; j
<atoms
->grps
[egcVCM
].nr
; j
++)
894 for(ai
=0; ai
<atoms
->nr
; ai
++)
895 if (atoms
->atom
[ai
].grpnr
[egcTC
] == i
) {
896 na_vcm
[atoms
->atom
[ai
].grpnr
[egcVCM
]]++;
899 /* Correct for VCM removal according to the fraction of each VCM
900 * group present in this TC group.
902 nrdf_uc
= opts
->nrdf
[i
];
904 for(j
=0; j
<atoms
->grps
[egcVCM
].nr
; j
++)
905 opts
->nrdf
[i
] += nrdf_uc
*((double)na_vcm
[j
]/(double)na_tot
)*
906 (nrdf_vcm
[j
] - n_sub
)/nrdf_vcm
[j
];
909 for(i
=0; (i
<atoms
->grps
[egcTC
].nr
); i
++) {
910 if (opts
->nrdf
[i
] < 0)
913 "Number of degrees of freedom in T-Coupling group %s is %.2f\n",
914 gnames
[atoms
->grps
[egcTC
].nm_ind
[i
]],opts
->nrdf
[i
]);
922 static void decode_cos(char *s
,t_cosines
*cosine
)
925 char format
[STRLEN
],f1
[STRLEN
];
936 sscanf(t
,"%d",&(cosine
->n
));
937 if (cosine
->n
<= 0) {
940 snew(cosine
->a
,cosine
->n
);
941 snew(cosine
->phi
,cosine
->n
);
943 sprintf(format
,"%%*d");
944 for(i
=0; (i
<cosine
->n
); i
++) {
947 if (sscanf(t
,f1
,&a
,&phi
) < 2)
948 fatal_error(0,"Invalid input for electric field shift: '%s'",t
);
951 strcat(format
,"%*lf%*lf");
958 void do_index(char *ndx
,
960 t_atoms
*atoms
,bool bVerbose
,
961 t_inputrec
*ir
,t_idef
*idef
,int *forward
,rvec
*v
)
964 char warnbuf
[STRLEN
],**gnames
;
965 int nr
,ntcg
,ntau_t
,nref_t
,nacc
,nofg
,nSA
,nSA_points
,nSA_time
,nSA_temp
;
966 int nacg
,nfreeze
,nfrdim
,nenergy
,nuser
,negexcl
;
967 char *ptr1
[MAXPTR
],*ptr2
[MAXPTR
],*ptr3
[MAXPTR
];
970 bool bExcl
,bSetTCpar
,bAnneal
;
973 fprintf(stderr
,"processing index file...\n");
979 analyse(atoms
,grps
,&gnames
,FALSE
,TRUE
);
980 /* Do not shuffle the index when it is based on atoms */
983 grps
= init_index(ndx
,&gnames
);
985 snew(atoms
->grpname
,grps
->nr
+1);
987 for(i
=0; (i
<grps
->nr
); i
++)
988 atoms
->grpname
[i
]=put_symtab(symtab
,gnames
[i
]);
989 atoms
->grpname
[i
]=put_symtab(symtab
,"rest");
991 srenew(gnames
,grps
->nr
+1);
992 gnames
[restnm
]=*(atoms
->grpname
[i
]);
993 atoms
->ngrpname
=grps
->nr
+1;
995 for(i
=0; (i
<atoms
->nr
); i
++)
996 for(j
=0; (j
<egcNR
); j
++)
997 atoms
->atom
[i
].grpnr
[j
]=NOGID
;
999 ntau_t
= str_nelem(tau_t
,MAXPTR
,ptr1
);
1000 nref_t
= str_nelem(ref_t
,MAXPTR
,ptr2
);
1001 ntcg
= str_nelem(tcgrps
,MAXPTR
,ptr3
);
1002 if ((ntau_t
!= ntcg
) || (nref_t
!= ntcg
))
1003 fatal_error(0,"Invalid T coupling input: %d groups, %d ref_t values and "
1004 "%d tau_t values",ntcg
,nref_t
,ntau_t
);
1008 do_numbering(atoms
,ntcg
,ptr3
,grps
,gnames
,egcTC
,
1009 restnm
,forward
,FALSE
,bVerbose
);
1010 nr
=atoms
->grps
[egcTC
].nr
;
1012 snew(ir
->opts
.nrdf
,nr
);
1013 snew(ir
->opts
.tau_t
,nr
);
1014 snew(ir
->opts
.ref_t
,nr
);
1015 bSetTCpar
= ir
->etc
|| ir
->eI
==eiSD
;
1016 if (ir
->eI
==eiBD
&& ir
->bd_fric
==0) {
1017 fprintf(stderr
,"bd_fric=0, so tau_t will be used as the inverse friction constant(s)\n");
1022 fatal_error(0,"Not enough ref_t and tau_t values!");
1023 for(i
=0; (i
<nr
); i
++) {
1024 ir
->opts
.tau_t
[i
]=atof(ptr1
[i
]);
1025 if (ir
->opts
.tau_t
[i
] < 0)
1026 fatal_error(0,"tau_t for group %d negative",i
);
1028 for(i
=0; (i
<nr
); i
++) {
1029 ir
->opts
.ref_t
[i
]=atof(ptr2
[i
]);
1030 if (ir
->opts
.ref_t
[i
] < 0)
1031 fatal_error(0,"ref_t for group %d negative",i
);
1035 /* Simulated annealing for each group. There are nr groups */
1036 nSA
= str_nelem(anneal
,MAXPTR
,ptr1
);
1037 if(nSA
>0 && nSA
!= nr
)
1038 fatal_error(0,"Not enough annealing values: %d (for %d groups)\n",nSA
,nr
);
1040 snew(ir
->opts
.annealing
,nr
);
1041 snew(ir
->opts
.anneal_npoints
,nr
);
1042 snew(ir
->opts
.anneal_time
,nr
);
1043 snew(ir
->opts
.anneal_temp
,nr
);
1045 fprintf(stderr
,"Not using any simulated annealing\n");
1047 ir
->opts
.annealing
[i
]=eannNO
;
1048 ir
->opts
.anneal_npoints
[i
]=0;
1049 ir
->opts
.anneal_time
[i
]=NULL
;
1050 ir
->opts
.anneal_temp
[i
]=NULL
;
1055 if(ptr1
[i
][0]=='n' || ptr1
[i
][0]=='N') {
1056 ir
->opts
.annealing
[i
]=eannNO
;
1057 } else if(ptr1
[i
][0]=='s'|| ptr1
[i
][0]=='S') {
1058 ir
->opts
.annealing
[i
]=eannSINGLE
;
1060 } else if(ptr1
[i
][0]=='p'|| ptr1
[i
][0]=='P') {
1061 ir
->opts
.annealing
[i
]=eannPERIODIC
;
1066 /* Read the other fields too */
1067 nSA_points
= str_nelem(anneal_npoints
,MAXPTR
,ptr1
);
1069 fatal_error(0,"Found %d annealing_npoints values for %d groups\n",nSA_points
,nSA
);
1070 for(k
=0,i
=0;i
<nr
;i
++) {
1071 ir
->opts
.anneal_npoints
[i
]=strtol(ptr1
[i
],NULL
,10);
1072 if(ir
->opts
.anneal_npoints
[i
]==1)
1073 fatal_error(0,"Please specify at least a start and an end point for annealing\n");
1074 snew(ir
->opts
.anneal_time
[i
],ir
->opts
.anneal_npoints
[i
]);
1075 snew(ir
->opts
.anneal_temp
[i
],ir
->opts
.anneal_npoints
[i
]);
1076 k
+= ir
->opts
.anneal_npoints
[i
];
1079 nSA_time
= str_nelem(anneal_time
,MAXPTR
,ptr1
);
1081 fatal_error(0,"Found %d annealing_time values, wanter %d\n",nSA_time
,k
);
1082 nSA_temp
= str_nelem(anneal_temp
,MAXPTR
,ptr2
);
1084 fatal_error(0,"Found %d annealing_temp values, wanted %d\n",nSA_temp
,k
);
1085 for(i
=0,k
=0;i
<nr
;i
++) {
1086 if(ir
->opts
.anneal_time
[i
][0] > (ir
->init_t
+GMX_REAL_EPS
))
1087 fatal_error(0,"First time point for annealing > init_t.\n");
1089 for(j
=0;j
<ir
->opts
.anneal_npoints
[i
];j
++) {
1090 ir
->opts
.anneal_time
[i
][j
]=atof(ptr1
[k
]);
1091 ir
->opts
.anneal_temp
[i
][j
]=atof(ptr2
[k
]);
1092 if(j
>0 && (ir
->opts
.anneal_time
[i
][j
]<ir
->opts
.anneal_time
[i
][j
-1]))
1093 fatal_error(0,"Annealing timepoints out of order: t=%f comes after t=%f\n",
1094 ir
->opts
.anneal_time
[i
][j
],ir
->opts
.anneal_time
[i
][j
-1]);
1095 if(ir
->opts
.anneal_temp
[i
][j
]<0)
1096 fatal_error(0,"Found negative temperature in annealing: %f\n",ir
->opts
.anneal_temp
[i
][j
]);
1100 /* Print out some summary information, to make sure we got it right */
1101 for(i
=0,k
=0;i
<nr
;i
++) {
1102 if(ir
->opts
.annealing
[i
]!=eannNO
) {
1103 j
=atoms
->grps
[egcTC
].nm_ind
[i
];
1104 fprintf(stderr
,"Simulated annealing for group %s: %s, %d timepoints\n",
1105 *(atoms
->grpname
[j
]),eann_names
[ir
->opts
.annealing
[i
]],
1106 ir
->opts
.anneal_npoints
[i
]);
1107 fprintf(stderr
,"Time (ps) Temperature (K)\n");
1108 /* All terms except the last one */
1109 for(j
=0;j
<(ir
->opts
.anneal_npoints
[i
]-1);j
++)
1110 fprintf(stderr
,"%9.1f %5.1f\n",ir
->opts
.anneal_time
[i
][j
],ir
->opts
.anneal_temp
[i
][j
]);
1112 /* Finally the last one */
1113 j
= ir
->opts
.anneal_npoints
[i
]-1;
1114 if(ir
->opts
.annealing
[i
]==eannSINGLE
)
1115 fprintf(stderr
,"%9.1f- %5.1f\n",ir
->opts
.anneal_time
[i
][j
],ir
->opts
.anneal_temp
[i
][j
]);
1117 fprintf(stderr
,"%9.1f %5.1f\n",ir
->opts
.anneal_time
[i
][j
],ir
->opts
.anneal_temp
[i
][j
]);
1118 if(fabs(ir
->opts
.anneal_temp
[i
][j
]-ir
->opts
.anneal_temp
[i
][0])>GMX_REAL_EPS
)
1119 fprintf(stderr
,"Note: There is a temperature jump when your annealing loops back.\n");
1127 nacc
= str_nelem(acc
,MAXPTR
,ptr1
);
1128 nacg
= str_nelem(accgrps
,MAXPTR
,ptr2
);
1129 if (nacg
*DIM
!= nacc
)
1130 fatal_error(0,"Invalid Acceleration input: %d groups and %d acc. values",
1132 do_numbering(atoms
,nacg
,ptr2
,grps
,gnames
,egcACC
,
1133 restnm
,forward
,FALSE
,bVerbose
); nr
=atoms
->grps
[egcACC
].nr
;
1134 snew(ir
->opts
.acc
,nr
);
1137 for(i
=k
=0; (i
<nacg
); i
++)
1138 for(j
=0; (j
<DIM
); j
++,k
++)
1139 ir
->opts
.acc
[i
][j
]=atof(ptr1
[k
]);
1141 for(j
=0; (j
<DIM
); j
++)
1142 ir
->opts
.acc
[i
][j
]=0;
1144 nfrdim
= str_nelem(frdim
,MAXPTR
,ptr1
);
1145 nfreeze
= str_nelem(freeze
,MAXPTR
,ptr2
);
1146 if (nfrdim
!= DIM
*nfreeze
)
1147 fatal_error(0,"Invalid Freezing input: %d groups and %d freeze values",
1149 do_numbering(atoms
,nfreeze
,ptr2
,grps
,gnames
,egcFREEZE
,
1150 restnm
,forward
,FALSE
,bVerbose
);
1151 nr
=atoms
->grps
[egcFREEZE
].nr
;
1153 snew(ir
->opts
.nFreeze
,nr
);
1154 for(i
=k
=0; (i
<nfreeze
); i
++)
1155 for(j
=0; (j
<DIM
); j
++,k
++) {
1156 ir
->opts
.nFreeze
[i
][j
]=(strncasecmp(ptr1
[k
],"Y",1)==0);
1157 if (!ir
->opts
.nFreeze
[i
][j
]) {
1158 if (strncasecmp(ptr1
[k
],"N",1) != 0) {
1159 sprintf(warnbuf
,"Please use Y(ES) or N(O) for freezedim only "
1160 "(not %s)", ptr1
[k
]);
1166 for(j
=0; (j
<DIM
); j
++)
1167 ir
->opts
.nFreeze
[i
][j
]=0;
1169 nenergy
=str_nelem(energy
,MAXPTR
,ptr1
);
1170 do_numbering(atoms
,nenergy
,ptr1
,grps
,gnames
,egcENER
,
1171 restnm
,forward
,FALSE
,bVerbose
);
1172 ir
->opts
.ngener
=atoms
->grps
[egcENER
].nr
;
1173 nuser
=str_nelem(vcm
,MAXPTR
,ptr1
);
1174 do_numbering(atoms
,nuser
,ptr1
,grps
,gnames
,egcVCM
,
1175 restnm
,forward
,FALSE
,bVerbose
);
1177 /* Now we have filled the freeze struct, so we can calculate NRDF */
1178 calc_nrdf(atoms
,idef
,&(ir
->opts
),gnames
,ir
->nstcomm
);
1182 /* Must check per group! */
1183 for(i
=0; (i
<ir
->opts
.ngtc
); i
++)
1184 ntot
+= ir
->opts
.nrdf
[i
];
1185 if (ntot
!= (DIM
*atoms
->nr
)) {
1186 fac
= sqrt(ntot
/(DIM
*atoms
->nr
));
1188 fprintf(stderr
,"Scaling velocities by a factor of %.3f to account for constraints\n"
1189 "and removal of center of mass motion\n",fac
);
1190 for(i
=0; (i
<atoms
->nr
); i
++)
1191 svmul(fac
,v
[i
],v
[i
]);
1195 nuser
=str_nelem(user1
,MAXPTR
,ptr1
);
1196 do_numbering(atoms
,nuser
,ptr1
,grps
,gnames
,egcUser1
,
1197 restnm
,forward
,FALSE
,bVerbose
);
1198 nuser
=str_nelem(user2
,MAXPTR
,ptr1
);
1199 do_numbering(atoms
,nuser
,ptr1
,grps
,gnames
,egcUser2
,
1200 restnm
,forward
,FALSE
,bVerbose
);
1201 nuser
=str_nelem(xtc_grps
,MAXPTR
,ptr1
);
1202 do_numbering(atoms
,nuser
,ptr1
,grps
,gnames
,egcXTC
,
1203 restnm
,forward
,TRUE
,bVerbose
);
1204 nofg
= str_nelem(orirefitgrp
,MAXPTR
,ptr1
);
1205 do_numbering(atoms
,nofg
,ptr1
,grps
,gnames
,egcORFIT
,
1206 restnm
,forward
,FALSE
,bVerbose
);
1209 for(i
=0; (i
<egcNR
); i
++) {
1210 fprintf(stderr
,"%-16s has %d element(s):",gtypes
[i
],atoms
->grps
[i
].nr
);
1211 for(j
=0; (j
<atoms
->grps
[i
].nr
); j
++)
1212 fprintf(stderr
," %s",*(atoms
->grpname
[atoms
->grps
[i
].nm_ind
[j
]]));
1213 fprintf(stderr
,"\n");
1216 negexcl
=str_nelem(egexcl
,MAXPTR
,ptr1
);
1217 if (negexcl
% 2 != 0)
1218 fatal_error(0,"The number of groups for energygrp_excl is odd");
1219 nr
=atoms
->grps
[egcENER
].nr
;
1220 snew(ir
->opts
.eg_excl
,nr
*nr
);
1222 for(i
=0; i
<negexcl
/2; i
++) {
1225 strcasecmp(ptr1
[2*i
],gnames
[atoms
->grps
[egcENER
].nm_ind
[j
]]))
1228 fatal_error(0,"%s in energygrp_excl is not an energy group\n",
1232 strcasecmp(ptr1
[2*i
+1],gnames
[atoms
->grps
[egcENER
].nm_ind
[k
]]))
1235 fatal_error(0,"%s in energygrp_excl is not an energy group\n",
1237 if ((j
< nr
) && (k
< nr
)) {
1238 ir
->opts
.eg_excl
[nr
*j
+k
] = TRUE
;
1239 ir
->opts
.eg_excl
[nr
*k
+j
] = TRUE
;
1243 if (bExcl
&& EEL_LR(ir
->coulombtype
))
1244 warning("Can not exclude the lattice Coulomb energy between energy groups");
1246 decode_cos(efield_x
,&(ir
->ex
[XX
]));
1247 decode_cos(efield_xt
,&(ir
->et
[XX
]));
1248 decode_cos(efield_y
,&(ir
->ex
[YY
]));
1249 decode_cos(efield_yt
,&(ir
->et
[YY
]));
1250 decode_cos(efield_z
,&(ir
->ex
[ZZ
]));
1251 decode_cos(efield_zt
,&(ir
->et
[ZZ
]));
1253 for(i
=0; (i
<grps
->nr
); i
++)
1260 static void check_disre(t_topology
*sys
)
1262 t_functype
*functype
;
1264 int i
,ndouble
,ftype
;
1265 int label
,old_label
;
1267 if (sys
->idef
.il
[F_DISRES
].nr
) {
1268 functype
= sys
->idef
.functype
;
1269 ip
= sys
->idef
.iparams
;
1272 for(i
=0; i
<sys
->idef
.ntypes
; i
++) {
1273 ftype
= functype
[i
];
1274 if (ftype
== F_DISRES
) {
1275 label
= ip
[i
].disres
.label
;
1276 if (label
== old_label
) {
1277 fprintf(stderr
,"Distance restraint index %d occurs twice\n",label
);
1284 fatal_error(0,"Found %d double distance restraint indices,\n"
1285 "probably the parameters for multiple pairs in one restraint "
1286 "are not identical\n",ndouble
);
1290 void triple_check(char *mdparin
,t_inputrec
*ir
,t_topology
*sys
,int *nerror
)
1297 /* Generalized reaction field */
1298 if (ir
->opts
.ngtc
== 0) {
1299 sprintf(err_buf
,"No temperature coupling while using coulombtype %s",
1301 CHECK(ir
->coulombtype
== eelGRF
);
1304 sprintf(err_buf
,"When using coulombtype = %s"
1305 " ref_t for temperature coupling should be > 0",
1307 CHECK((ir
->coulombtype
== eelGRF
) && (ir
->opts
.ref_t
[0] <= 0));
1311 snew(mgrp
,sys
->atoms
.grps
[egcACC
].nr
);
1312 for(i
=0; (i
<sys
->atoms
.nr
); i
++)
1313 mgrp
[sys
->atoms
.atom
[i
].grpnr
[egcACC
]] += sys
->atoms
.atom
[i
].m
;
1315 for(i
=0; (i
<sys
->atoms
.grps
[egcACC
].nr
); i
++) {
1316 for(m
=0; (m
<DIM
); m
++)
1317 acc
[m
]+=ir
->opts
.acc
[i
][m
]*mgrp
[i
];
1320 for(m
=0; (m
<DIM
); m
++) {
1321 if (fabs(acc
[m
]) > 1e-6) {
1322 char *dim
[DIM
] = { "X", "Y", "Z" };
1324 "Net Acceleration in %s direction, will %s be corrected\n",
1325 dim
[m
],ir
->nstcomm
!= 0 ? "" : "not");
1326 if (ir
->nstcomm
!= 0) {
1328 for (i
=0; (i
<sys
->atoms
.grps
[egcACC
].nr
); i
++)
1329 ir
->opts
.acc
[i
][m
]-=acc
[m
];
1338 void double_check(t_inputrec
*ir
,matrix box
,t_molinfo
*mol
,int *nerror
)
1340 real min_size
,rlong
;
1344 ptr
= check_box(box
);
1351 if( (ir
->eConstrAlg
==estSHAKE
) &&
1352 (mol
->plist
[F_SHAKE
].nr
> 0) &&
1353 (ir
->shake_tol
<= 0.0) ) {
1354 fprintf(stderr
,"ERROR: shake_tol must be > 0 instead of %g\n",
1359 if (ir
->ePBC
!= epbcNONE
) {
1360 rlong
= max(ir
->rlist
,max(ir
->rcoulomb
,ir
->rvdw
));
1361 bTWIN
= (rlong
> ir
->rlist
);
1362 if (ir
->ns_type
==ensGRID
) {
1363 min_size
= min(norm2(box
[XX
]),min(norm2(box
[YY
]),norm2(box
[ZZ
])));
1364 if (sqr(2*rlong
) >= min_size
) {
1365 fprintf(stderr
,"ERROR: One of the box vectors is shorter than twice the cut-off length. Increase the box size or decrease %s.\n",
1366 bTWIN
? "rcoulomb":"rlist");
1370 min_size
= min(box
[XX
][XX
],min(box
[YY
][YY
],box
[ZZ
][ZZ
]));
1371 if (2*rlong
>= min_size
) {
1372 fprintf(stderr
,"ERROR: One of the box lengths is smaller than twice the cut-off length. Increase the box size or decrease rlist.");
1375 fprintf(stderr
,"Grid search might allow larger cut-off's than simple search with triclinic boxes.");