Merge branch release-2018
[alexxy/gromacs.git] / src / gromacs / gmxpreprocess / readpull.cpp
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5  * Copyright (c) 2001-2004, The GROMACS development team.
6  * Copyright (c) 2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
7  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8  * and including many others, as listed in the AUTHORS file in the
9  * top-level source directory and at http://www.gromacs.org.
10  *
11  * GROMACS is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public License
13  * as published by the Free Software Foundation; either version 2.1
14  * of the License, or (at your option) any later version.
15  *
16  * GROMACS is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with GROMACS; if not, see
23  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
25  *
26  * If you want to redistribute modifications to GROMACS, please
27  * consider that scientific software is very special. Version
28  * control is crucial - bugs must be traceable. We will be happy to
29  * consider code for inclusion in the official distribution, but
30  * derived work must not be called official GROMACS. Details are found
31  * in the README & COPYING files - if they are missing, get the
32  * official version at http://www.gromacs.org.
33  *
34  * To help us fund GROMACS development, we humbly ask that you cite
35  * the research papers on the package. Check out http://www.gromacs.org.
36  */
37 #include "gmxpre.h"
38
39 #include <cassert>
40 #include <cstdlib>
41 #include <cstring>
42
43 #include "gromacs/domdec/localatomsetmanager.h"
44 #include "gromacs/fileio/readinp.h"
45 #include "gromacs/fileio/warninp.h"
46 #include "gromacs/gmxpreprocess/readir.h"
47 #include "gromacs/math/vec.h"
48 #include "gromacs/mdlib/mdatoms.h"
49 #include "gromacs/mdlib/mdrun.h"
50 #include "gromacs/mdtypes/inputrec.h"
51 #include "gromacs/mdtypes/md_enums.h"
52 #include "gromacs/mdtypes/pull-params.h"
53 #include "gromacs/pbcutil/pbc.h"
54 #include "gromacs/pulling/pull.h"
55 #include "gromacs/topology/topology.h"
56 #include "gromacs/utility/cstringutil.h"
57 #include "gromacs/utility/fatalerror.h"
58 #include "gromacs/utility/futil.h"
59 #include "gromacs/utility/smalloc.h"
60
61
62 static void string2dvec(const char buf[], dvec nums)
63 {
64     double dum;
65
66     if (sscanf(buf, "%lf%lf%lf%lf", &nums[0], &nums[1], &nums[2], &dum) != 3)
67     {
68         gmx_fatal(FARGS, "Expected three numbers at input line %s", buf);
69     }
70 }
71
72 static void init_pull_group(t_pull_group *pg,
73                             const char   *wbuf)
74 {
75     double d;
76     int    n;
77
78     pg->nweight = 0;
79     while (sscanf(wbuf, "%lf %n", &d, &n) == 1)
80     {
81         if (pg->nweight % 100 == 0)
82         {
83             srenew(pg->weight, pg->nweight+100);
84         }
85         pg->weight[pg->nweight++] = d;
86         wbuf += n;
87     }
88 }
89
90 static void process_pull_dim(char *dim_buf, ivec dim, const t_pull_coord *pcrd)
91 {
92     int           ndim, d, nchar;
93     char         *ptr, pulldim1[STRLEN];
94
95     ptr  = dim_buf;
96     ndim = 0;
97     for (d = 0; d < DIM; d++)
98     {
99         if (sscanf(ptr, "%s%n", pulldim1, &nchar) != 1)
100         {
101             gmx_fatal(FARGS, "Less than 3 pull dimensions given in pull_dim: '%s'",
102                       dim_buf);
103         }
104
105         if (gmx_strncasecmp(pulldim1, "N", 1) == 0)
106         {
107             dim[d] = 0;
108         }
109         else if (gmx_strncasecmp(pulldim1, "Y", 1) == 0)
110         {
111             dim[d] = 1;
112             ndim++;
113         }
114         else
115         {
116             gmx_fatal(FARGS, "Please use Y(ES) or N(O) for pull_dim only (not %s)",
117                       pulldim1);
118         }
119         ptr += nchar;
120     }
121     if (ndim == 0)
122     {
123         gmx_fatal(FARGS, "All entries in pull dim are N");
124     }
125     if ((pcrd->eGeom == epullgDIHEDRAL) && (ndim < 3))
126     {
127         gmx_fatal(FARGS, "Pull geometry dihedral is only useful with pull-dim = Y Y Y");
128     }
129     if ((pcrd->eGeom == epullgANGLE || pcrd->eGeom == epullgANGLEAXIS ) && (ndim < 2))
130     {
131         gmx_fatal(FARGS, "Pull geometry %s is only useful with pull-dim = Y for at least 2 dimensions",
132                   EPULLGEOM(pcrd->eGeom));
133     }
134 }
135
136 static void init_pull_coord(t_pull_coord *pcrd, int coord_index_for_output,
137                             char *dim_buf,
138                             const char *origin_buf, const char *vec_buf,
139                             warninp_t wi)
140 {
141     int    m;
142     dvec   origin, vec;
143     char   buf[STRLEN];
144
145     if (pcrd->eType == epullCONSTRAINT && (pcrd->eGeom == epullgCYL ||
146                                            pcrd->eGeom == epullgDIRRELATIVE ||
147                                            pcrd->eGeom == epullgANGLE ||
148                                            pcrd->eGeom == epullgANGLEAXIS ||
149                                            pcrd->eGeom == epullgDIHEDRAL))
150     {
151         gmx_fatal(FARGS, "Pulling of type %s can not be combined with geometry %s. Consider using pull type %s.",
152                   epull_names[pcrd->eType],
153                   epullg_names[pcrd->eGeom],
154                   epull_names[epullUMBRELLA]);
155     }
156
157     if (pcrd->eType == epullEXTERNAL)
158     {
159         if (pcrd->externalPotentialProvider[0] == '\0')
160         {
161             sprintf(buf, "The use of pull type '%s' for pull coordinate %d requires that the name of the module providing the potential external is set with the option %s%d%s",
162                     epull_names[pcrd->eType], coord_index_for_output,
163                     "pull-coord", coord_index_for_output, "-potential-provider");
164             warning_error(wi, buf);
165         }
166
167         if (pcrd->rate != 0)
168         {
169             sprintf(buf, "The use of pull type '%s' for pull coordinate %d requires that the pull rate is zero",
170                     epull_names[pcrd->eType], coord_index_for_output);
171             warning_error(wi, buf);
172         }
173
174         if (pcrd->eGeom == epullgCYL)
175         {
176             /* Warn the user of a PBC restriction, caused by the fact that
177              * there is no reference value with an external pull potential.
178              */
179             sprintf(buf, "With pull type '%s' and geometry '%s', the distance component along the cylinder axis between atoms in the cylinder group and the COM of the pull group should be smaller than half the box length",
180                     epull_names[pcrd->eType], epullg_names[pcrd->eGeom]);
181             warning_note(wi, buf);
182         }
183     }
184
185     process_pull_dim(dim_buf, pcrd->dim, pcrd);
186
187     string2dvec(origin_buf, origin);
188     if (pcrd->group[0] != 0 && dnorm(origin) > 0)
189     {
190         gmx_fatal(FARGS, "The pull origin can only be set with an absolute reference");
191     }
192
193     /* Check the given initial reference value and warn for dangerous values */
194     if (pcrd->eGeom == epullgDIST)
195     {
196         if (pcrd->bStart && pcrd->init < 0)
197         {
198             sprintf(buf, "The initial reference distance set by pull-coord-init is set to a negative value (%g) with geometry %s while distances need to be non-negative. "
199                     "This may work, since you have set pull-coord-start to 'yes' which modifies this value, but only for certain starting distances. "
200                     "If this is a mistake you may want to use geometry %s instead.",
201                     pcrd->init, EPULLGEOM(pcrd->eGeom), EPULLGEOM(epullgDIR));
202             warning(wi, buf);
203         }
204     }
205     else if (pcrd->eGeom == epullgANGLE || pcrd->eGeom == epullgANGLEAXIS)
206     {
207         if (pcrd->bStart && (pcrd->init < 0 || pcrd->init > 180))
208         {
209             /* This value of pcrd->init may be ok depending on pcrd->bStart which modifies pcrd->init later on */
210             sprintf(buf, "The initial reference angle set by pull-coord-init (%g) is outside of the allowed range [0, 180] degrees for geometry (%s). "
211                     "This may work, since you have set pull-coord-start to 'yes' which modifies this value, but only for certain starting angles.",
212                     pcrd->init, EPULLGEOM(pcrd->eGeom));
213             warning(wi, buf);
214         }
215     }
216     else if (pcrd->eGeom == epullgDIHEDRAL)
217     {
218         if (pcrd->bStart && (pcrd->init < -180 || pcrd->init > 180))
219         {
220             sprintf(buf, "The initial reference angle set by pull-coord-init (%g) is outside of the allowed range [-180, 180] degrees for geometry (%s). "
221                     "This may work, since you have set pull-coord-start to 'yes' which modifies this value, but only for certain starting angles.",
222                     pcrd->init, EPULLGEOM(pcrd->eGeom));
223             warning(wi, buf);
224         }
225     }
226
227     /* Check and set the pull vector */
228     clear_dvec(vec);
229     string2dvec(vec_buf, vec);
230
231     if (pcrd->eGeom == epullgDIR || pcrd->eGeom == epullgCYL || pcrd->eGeom == epullgDIRPBC || pcrd->eGeom == epullgANGLEAXIS)
232     {
233         if (dnorm2(vec) == 0)
234         {
235             gmx_fatal(FARGS, "With pull geometry %s the pull vector can not be 0,0,0",
236                       epullg_names[pcrd->eGeom]);
237         }
238         for (int d = 0; d < DIM; d++)
239         {
240             if (vec[d] != 0 && pcrd->dim[d] == 0)
241             {
242                 gmx_fatal(FARGS, "pull-coord-vec has non-zero %c-component while pull_dim for the %c-dimension is set to N", 'x'+d, 'x'+d);
243             }
244         }
245
246         /* Normalize the direction vector */
247         dsvmul(1/dnorm(vec), vec, vec);
248     }
249     else /* This case is for are all the geometries where the pull vector is not used */
250     {
251         if (dnorm2(vec) > 0)
252         {
253             sprintf(buf, "A pull vector is given (%g  %g  %g) but will not be used with geometry %s. If you really want to use this "
254                     "vector, consider using geometry %s instead.",
255                     vec[0], vec[1], vec[2], EPULLGEOM(pcrd->eGeom),
256                     pcrd->eGeom == epullgANGLE ? EPULLGEOM(epullgANGLEAXIS) : EPULLGEOM(epullgDIR));
257             warning(wi, buf);
258         }
259     }
260     for (m = 0; m < DIM; m++)
261     {
262         pcrd->origin[m] = origin[m];
263         pcrd->vec[m]    = vec[m];
264     }
265 }
266
267 char **read_pullparams(std::vector<t_inpfile> *inp,
268                        pull_params_t          *pull,
269                        warninp_t               wi)
270 {
271     int                    nscan, idum;
272     char                 **grpbuf;
273     char                   buf[STRLEN];
274     char                   provider[STRLEN], groups[STRLEN], dim_buf[STRLEN];
275     char                   wbuf[STRLEN], origin_buf[STRLEN], vec_buf[STRLEN];
276
277     t_pull_group          *pgrp;
278     t_pull_coord          *pcrd;
279
280     /* read pull parameters */
281     printStringNoNewline(inp, "Cylinder radius for dynamic reaction force groups (nm)");
282     pull->cylinder_r     = get_ereal(inp, "pull-cylinder-r", 1.5, wi);
283     pull->constr_tol     = get_ereal(inp, "pull-constr-tol", 1E-6, wi);
284     pull->bPrintCOM      = (get_eeenum(inp, "pull-print-com", yesno_names, wi) != 0);
285     pull->bPrintRefValue = (get_eeenum(inp, "pull-print-ref-value", yesno_names, wi) != 0);
286     pull->bPrintComp     = (get_eeenum(inp, "pull-print-components", yesno_names, wi) != 0);
287     pull->nstxout        = get_eint(inp, "pull-nstxout", 50, wi);
288     pull->nstfout        = get_eint(inp, "pull-nstfout", 50, wi);
289     printStringNoNewline(inp, "Number of pull groups");
290     pull->ngroup = get_eint(inp, "pull-ngroups", 1, wi);
291     printStringNoNewline(inp, "Number of pull coordinates");
292     pull->ncoord = get_eint(inp, "pull-ncoords", 1, wi);
293
294     if (pull->ngroup < 1)
295     {
296         gmx_fatal(FARGS, "pull-ngroups should be >= 1");
297     }
298     /* We always add an absolute reference group (index 0), even if not used */
299     pull->ngroup += 1;
300
301     if (pull->ncoord < 1)
302     {
303         gmx_fatal(FARGS, "pull-ncoords should be >= 1");
304     }
305
306     snew(pull->group, pull->ngroup);
307
308     snew(pull->coord, pull->ncoord);
309
310     /* pull group options */
311     printStringNoNewline(inp, "Group and coordinate parameters");
312
313     /* Read the pull groups */
314     snew(grpbuf, pull->ngroup);
315     /* Group 0 is the absolute reference, we don't read anything for 0 */
316     for (int groupNum = 1; groupNum < pull->ngroup; groupNum++)
317     {
318         pgrp = &pull->group[groupNum];
319         snew(grpbuf[groupNum], STRLEN);
320         sprintf(buf, "pull-group%d-name", groupNum);
321         setStringEntry(inp, buf, grpbuf[groupNum], "");
322         sprintf(buf, "pull-group%d-weights", groupNum);
323         setStringEntry(inp, buf, wbuf, "");
324         sprintf(buf, "pull-group%d-pbcatom", groupNum);
325         pgrp->pbcatom = get_eint(inp, buf, 0, wi);
326
327         /* Initialize the pull group */
328         init_pull_group(pgrp, wbuf);
329     }
330
331     /* Read the pull coordinates */
332     for (int coordNum = 1; coordNum < pull->ncoord + 1; coordNum++)
333     {
334         pcrd = &pull->coord[coordNum - 1];
335         sprintf(buf, "pull-coord%d-type", coordNum);
336         pcrd->eType = get_eeenum(inp, buf, epull_names, wi);
337         sprintf(buf, "pull-coord%d-potential-provider", coordNum);
338         setStringEntry(inp, buf, provider, "");
339         pcrd->externalPotentialProvider = gmx_strdup(provider);
340         sprintf(buf, "pull-coord%d-geometry", coordNum);
341         pcrd->eGeom = get_eeenum(inp, buf, epullg_names, wi);
342         sprintf(buf, "pull-coord%d-groups", coordNum);
343         setStringEntry(inp, buf, groups, "");
344
345         switch (pcrd->eGeom)
346         {
347             case epullgDIHEDRAL:
348                 pcrd->ngroup = 6; break;
349             case epullgDIRRELATIVE:
350             case epullgANGLE:
351                 pcrd->ngroup = 4; break;
352             default:
353                 pcrd->ngroup = 2; break;
354         }
355
356         nscan = sscanf(groups, "%d %d %d %d %d %d %d",
357                        &pcrd->group[0], &pcrd->group[1], &pcrd->group[2], &pcrd->group[3],
358                        &pcrd->group[4], &pcrd->group[5], &idum);
359         if (nscan != pcrd->ngroup)
360         {
361             sprintf(wbuf, "%s should contain %d pull group indices with geometry %s",
362                     buf, pcrd->ngroup, epullg_names[pcrd->eGeom]);
363             set_warning_line(wi, nullptr, -1);
364             warning_error(wi, wbuf);
365         }
366         for (int g = 0; g < pcrd->ngroup; g++)
367         {
368             if (pcrd->group[g] < 0 || pcrd->group[g] >= pull->ngroup)
369             {
370                 /* Quit with a fatal error to avoid invalid memory access */
371                 gmx_fatal(FARGS, "%s contains an invalid pull group %d, you should have %d <= group <= %d",
372                           buf, pcrd->group[g], 0, pull->ngroup - 1);
373             }
374         }
375
376         sprintf(buf, "pull-coord%d-dim", coordNum);
377         setStringEntry(inp, buf, dim_buf, "Y Y Y");
378         sprintf(buf, "pull-coord%d-origin", coordNum);
379         setStringEntry(inp, buf, origin_buf, "0.0 0.0 0.0");
380         sprintf(buf, "pull-coord%d-vec", coordNum);
381         setStringEntry(inp, buf, vec_buf, "0.0 0.0 0.0");
382         sprintf(buf, "pull-coord%d-start", coordNum);
383         pcrd->bStart = (get_eeenum(inp, buf, yesno_names, wi) != 0);
384         sprintf(buf, "pull-coord%d-init", coordNum);
385         pcrd->init = get_ereal(inp, buf, 0.0, wi);
386         sprintf(buf, "pull-coord%d-rate", coordNum);
387         pcrd->rate = get_ereal(inp, buf, 0.0, wi);
388         sprintf(buf, "pull-coord%d-k", coordNum);
389         pcrd->k = get_ereal(inp, buf, 0.0, wi);
390         sprintf(buf, "pull-coord%d-kB", coordNum);
391         pcrd->kB = get_ereal(inp, buf, pcrd->k, wi);
392
393         /* Initialize the pull coordinate */
394         init_pull_coord(pcrd, coordNum, dim_buf, origin_buf, vec_buf, wi);
395     }
396
397     return grpbuf;
398 }
399
400 void make_pull_groups(pull_params_t *pull,
401                       char **pgnames,
402                       const t_blocka *grps, char **gnames)
403 {
404     int           g, ig = -1, i;
405     t_pull_group *pgrp;
406
407     /* Absolute reference group (might not be used) is special */
408     pgrp          = &pull->group[0];
409     pgrp->nat     = 0;
410     pgrp->pbcatom = -1;
411
412     for (g = 1; g < pull->ngroup; g++)
413     {
414         pgrp = &pull->group[g];
415
416         if (strcmp(pgnames[g], "") == 0)
417         {
418             gmx_fatal(FARGS, "Pull option pull_group%d required by grompp has not been set.", g);
419         }
420
421         ig        = search_string(pgnames[g], grps->nr, gnames);
422         pgrp->nat = grps->index[ig+1] - grps->index[ig];
423
424         fprintf(stderr, "Pull group %d '%s' has %d atoms\n",
425                 g, pgnames[g], pgrp->nat);
426
427         if (pgrp->nat == 0)
428         {
429             gmx_fatal(FARGS, "Pull group %d '%s' is empty", g, pgnames[g]);
430         }
431
432         snew(pgrp->ind, pgrp->nat);
433         for (i = 0; i < pgrp->nat; i++)
434         {
435             pgrp->ind[i] = grps->a[grps->index[ig]+i];
436         }
437
438         if (pgrp->nweight > 0 && pgrp->nweight != pgrp->nat)
439         {
440             gmx_fatal(FARGS, "Number of weights (%d) for pull group %d '%s' does not match the number of atoms (%d)",
441                       pgrp->nweight, g, pgnames[g], pgrp->nat);
442         }
443
444         if (pgrp->nat == 1)
445         {
446             /* No pbc is required for this group */
447             pgrp->pbcatom = -1;
448         }
449         else
450         {
451             if (pgrp->pbcatom > 0)
452             {
453                 pgrp->pbcatom -= 1;
454             }
455             else if (pgrp->pbcatom == 0)
456             {
457                 pgrp->pbcatom = pgrp->ind[(pgrp->nat-1)/2];
458             }
459             else
460             {
461                 /* Use cosine weighting */
462                 pgrp->pbcatom = -1;
463             }
464         }
465     }
466 }
467
468 void make_pull_coords(pull_params_t *pull)
469 {
470     int           c;
471     t_pull_coord *pcrd;
472
473     for (c = 0; c < pull->ncoord; c++)
474     {
475         pcrd = &pull->coord[c];
476
477         if (pcrd->group[0] < 0 || pcrd->group[0] >= pull->ngroup ||
478             pcrd->group[1] < 0 || pcrd->group[1] >= pull->ngroup)
479         {
480             gmx_fatal(FARGS, "Pull group index in pull-coord%d-groups out of range, should be between %d and %d", c+1, 0, pull->ngroup+1);
481         }
482
483         if (pcrd->group[0] == pcrd->group[1])
484         {
485             gmx_fatal(FARGS, "Identical pull group indices in pull-coord%d-groups", c+1);
486         }
487
488         if (pcrd->eGeom == epullgCYL)
489         {
490             if (pull->group[pcrd->group[0]].nweight > 0)
491             {
492                 gmx_fatal(FARGS, "Weights are not supported for the reference group with cylinder pulling");
493             }
494         }
495     }
496 }
497
498 pull_t *set_pull_init(t_inputrec *ir, const gmx_mtop_t *mtop,
499                       rvec *x, matrix box, real lambda,
500                       warninp_t wi)
501 {
502     pull_params_t *pull;
503     pull_t        *pull_work;
504     t_pbc          pbc;
505     int            c;
506     double         t_start;
507
508     pull      = ir->pull;
509     gmx::LocalAtomSetManager atomSets;
510     pull_work = init_pull(nullptr, pull, ir, mtop, nullptr, &atomSets, lambda);
511     auto                     mdAtoms = gmx::makeMDAtoms(nullptr, *mtop, *ir, false);
512     auto                     md      = mdAtoms->mdatoms();
513     atoms2md(mtop, ir, -1, nullptr, mtop->natoms, mdAtoms.get());
514     if (ir->efep)
515     {
516         update_mdatoms(md, lambda);
517     }
518
519     set_pbc(&pbc, ir->ePBC, box);
520
521     t_start = ir->init_t + ir->init_step*ir->delta_t;
522
523     pull_calc_coms(nullptr, pull_work, md, &pbc, t_start, x, nullptr);
524
525     int groupThatFailsPbc = pullCheckPbcWithinGroups(*pull_work, x, pbc);
526     if (groupThatFailsPbc >= 0)
527     {
528         char buf[STRLEN];
529         sprintf(buf,
530                 "Pull group %d has atoms at a distance larger than %g times half the box size from the PBC atom (%d). If atoms are or will more beyond half the box size from the PBC atom, the COM will be ill defined.",
531                 groupThatFailsPbc,
532                 c_pullGroupPbcMargin,
533                 pull->group[groupThatFailsPbc].pbcatom);
534         set_warning_line(wi, nullptr, -1);
535         warning(wi, buf);
536     }
537
538     fprintf(stderr, "Pull group  natoms  pbc atom  distance at start  reference at t=0\n");
539     for (c = 0; c < pull->ncoord; c++)
540     {
541         t_pull_coord *pcrd;
542         t_pull_group *pgrp0, *pgrp1;
543         double        value;
544         real          init = 0;
545
546         pcrd  = &pull->coord[c];
547
548         pgrp0 = &pull->group[pcrd->group[0]];
549         pgrp1 = &pull->group[pcrd->group[1]];
550         fprintf(stderr, "%8d  %8d  %8d\n",
551                 pcrd->group[0], pgrp0->nat, pgrp0->pbcatom+1);
552         fprintf(stderr, "%8d  %8d  %8d ",
553                 pcrd->group[1], pgrp1->nat, pgrp1->pbcatom+1);
554
555         if (pcrd->bStart)
556         {
557             init       = pcrd->init;
558             pcrd->init = 0;
559         }
560
561         value  = get_pull_coord_value(pull_work, c, &pbc);
562
563         value *= pull_conversion_factor_internal2userinput(pcrd);
564         fprintf(stderr, " %10.3f %s", value, pull_coordinate_units(pcrd));
565
566         if (pcrd->bStart)
567         {
568             pcrd->init = value + init;
569         }
570
571         if (pcrd->eGeom == epullgDIST)
572         {
573             if (pcrd->init < 0)
574             {
575                 gmx_fatal(FARGS, "The initial pull distance (%g) needs to be non-negative with geometry %s. If you want a signed distance, use geometry %s instead.",
576                           pcrd->init, EPULLGEOM(pcrd->eGeom), EPULLGEOM(epullgDIR));
577             }
578
579             /* TODO: With a positive init but a negative rate things could still
580              * go wrong, but it might be fine if you don't pull too far.
581              * We should give a warning or note when there is only one pull dim
582              * active, since that is usually the problematic case when you should
583              * be using direction. We will do this later, since an already planned
584              * generalization of the pull code makes pull dim available here.
585              */
586         }
587         else if (pcrd->eGeom == epullgANGLE || pcrd->eGeom == epullgANGLEAXIS)
588         {
589             if (pcrd->init < 0 || pcrd->init > 180)
590             {
591                 gmx_fatal(FARGS,  "The initial pull reference angle (%g) is outside of the allowed range [0, 180] degrees.", pcrd->init);
592             }
593         }
594         else if (pcrd->eGeom == epullgDIHEDRAL)
595         {
596             if (pcrd->init < -180 || pcrd->init > 180)
597             {
598                 gmx_fatal(FARGS,  "The initial pull reference angle (%g) is outside of the allowed range [-180, 180] degrees.",
599                           pcrd->init);
600             }
601         }
602
603
604         fprintf(stderr, "     %10.3f %s\n", pcrd->init, pull_coordinate_units(pcrd));
605     }
606
607     return pull_work;
608 }