Part of preprocessing clean up.
Refs #2833
Change-Id: I4514edde34c978c2756f1c17471e0adde0736896
}
}
-void add_param(t_params *ps, int ai, int aj, const real *c, const char *s)
+void add_param(InteractionTypeParameters *ps, int ai, int aj, const real *c, const char *s)
{
int i;
ps->nr++;
}
-void add_imp_param(t_params *ps, int ai, int aj, int ak, int al, real c0, real c1,
+void add_imp_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, real c0, real c1,
const char *s)
{
pr_alloc(1, ps);
ps->nr++;
}
-void add_dih_param(t_params *ps, int ai, int aj, int ak, int al, real c0, real c1,
+void add_dih_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, real c0, real c1,
real c2, const char *s)
{
pr_alloc(1, ps);
ps->nr++;
}
-void add_cmap_param(t_params *ps, int ai, int aj, int ak, int al, int am, const char *s)
+void add_cmap_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, int am, const char *s)
{
pr_alloc(1, ps);
ps->param[ps->nr].ai() = ai;
ps->nr++;
}
-void add_vsite2_atoms(t_params *ps, int ai, int aj, int ak)
+void add_vsite2_atoms(InteractionTypeParameters *ps, int ai, int aj, int ak)
{
pr_alloc(1, ps);
ps->param[ps->nr].ai() = ai;
ps->nr++;
}
-void add_vsite2_param(t_params *ps, int ai, int aj, int ak, real c0)
+void add_vsite2_param(InteractionTypeParameters *ps, int ai, int aj, int ak, real c0)
{
pr_alloc(1, ps);
ps->param[ps->nr].ai() = ai;
ps->nr++;
}
-void add_vsite3_param(t_params *ps, int ai, int aj, int ak, int al,
+void add_vsite3_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al,
real c0, real c1)
{
pr_alloc(1, ps);
ps->nr++;
}
-void add_vsite3_atoms(t_params *ps, int ai, int aj, int ak, int al, bool bSwapParity)
+void add_vsite3_atoms(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, bool bSwapParity)
{
pr_alloc(1, ps);
ps->param[ps->nr].ai() = ai;
ps->nr++;
}
-void add_vsite4_atoms(t_params *ps, int ai, int aj, int ak, int al, int am)
+void add_vsite4_atoms(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, int am)
{
pr_alloc(1, ps);
ps->param[ps->nr].ai() = ai;
#include "gromacs/utility/real.h"
-struct t_params;
+struct InteractionTypeParameters;
struct PreprocessResidue;
-void add_param(t_params *ps, int ai, int aj, const real *c, const char *s);
+void add_param(InteractionTypeParameters *ps, int ai, int aj, const real *c, const char *s);
-void add_imp_param(t_params *ps, int ai, int aj, int ak, int al,
+void add_imp_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al,
real c0, real c1, const char *s);
-void add_dih_param(t_params *ps, int ai, int aj, int ak, int al,
+void add_dih_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al,
real c0, real c1, real c2, const char *s);
-void add_cmap_param(t_params *ps, int ai, int aj, int ak, int al, int am,
+void add_cmap_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, int am,
const char *s);
-void add_vsite2_atoms(t_params *ps, int ai, int aj, int ak);
+void add_vsite2_atoms(InteractionTypeParameters *ps, int ai, int aj, int ak);
-void add_vsite3_atoms(t_params *ps, int ai, int aj, int ak, int al,
+void add_vsite3_atoms(InteractionTypeParameters *ps, int ai, int aj, int ak, int al,
bool bSwapParity);
-void add_vsite2_param(t_params *ps, int ai, int aj, int ak, real c0);
+void add_vsite2_param(InteractionTypeParameters *ps, int ai, int aj, int ak, real c0);
-void add_vsite3_param(t_params *ps, int ai, int aj, int ak, int al,
+void add_vsite3_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al,
real c0, real c1);
-void add_vsite4_atoms(t_params *ps, int ai, int aj, int ak, int al,
+void add_vsite4_atoms(InteractionTypeParameters *ps, int ai, int aj, int ak, int al,
int am);
int search_jtype(const PreprocessResidue &localPpResidue, const char *name, bool bFirstRes);
}
}
-static void enter_function(const t_params *p, t_functype ftype, int comb, real reppow,
+static void enter_function(const InteractionTypeParameters *p, t_functype ftype, int comb, real reppow,
gmx_ffparams_t *ffparams, InteractionList *il,
bool bNB, bool bAppend)
{
}
}
-void convert_params(int atnr, t_params nbtypes[],
- gmx::ArrayRef<const MoleculeInformation> mi,
- const MoleculeInformation *intermolecular_interactions,
- int comb, double reppow, real fudgeQQ,
- gmx_mtop_t *mtop)
+void convertInteractionTypeParameters(int atnr, gmx::ArrayRef<const InteractionTypeParameters> nbtypes,
+ gmx::ArrayRef<const MoleculeInformation> mi,
+ const MoleculeInformation *intermolecular_interactions,
+ int comb, double reppow, real fudgeQQ,
+ gmx_mtop_t *mtop)
{
int i;
unsigned long flags;
{
molt->ilist[i].iatoms.clear();
- const t_params *plist = mi[mt].plist;
+ gmx::ArrayRef<const InteractionTypeParameters> plist = mi[mt].plist;
flags = interaction_function[i].flags;
if ((i != F_LJ) && (i != F_BHAM) && ((flags & IF_BOND) ||
{
(*mtop->intermolecular_ilist)[i].iatoms.clear();
- const t_params *plist = intermolecular_interactions->plist;
+ gmx::ArrayRef<const InteractionTypeParameters> plist = intermolecular_interactions->plist;
if (plist[i].nr > 0)
{
struct gmx_mtop_t;
struct MoleculeInformation;
-struct t_params;
+struct InteractionTypeParameters;
-void convert_params(int atnr, t_params nbtypes[],
- gmx::ArrayRef<const MoleculeInformation> mi,
- const MoleculeInformation *intermolecular_interactions,
- int comb, double reppow, real fudgeQQ,
- gmx_mtop_t *mtop);
+void convertInteractionTypeParameters(int atnr, gmx::ArrayRef<const InteractionTypeParameters> nbtypes,
+ gmx::ArrayRef<const MoleculeInformation> mi,
+ const MoleculeInformation *intermolecular_interactions,
+ int comb, double reppow, real fudgeQQ,
+ gmx_mtop_t *mtop);
#endif
sfree(index);
}
-static void cppar(t_param p[], int np, t_params plist[], int ftype)
+static void cppar(t_param p[], int np, gmx::ArrayRef<InteractionTypeParameters> plist, int ftype)
{
- int i, j, nral, nrfp;
- t_params *ps;
+ int i, j, nral, nrfp;
- ps = &plist[ftype];
+ InteractionTypeParameters *ps = &plist[ftype];
nral = NRAL(ftype);
nrfp = NRFP(ftype);
/* Generate pairs, angles and dihedrals from .rtp settings */
void gen_pad(t_nextnb *nnb, t_atoms *atoms, gmx::ArrayRef<const PreprocessResidue> rtpFFDB,
- t_params plist[], t_excls excls[], gmx::ArrayRef<MoleculePatchDatabase> globalPatches,
+ gmx::ArrayRef<InteractionTypeParameters> plist, t_excls excls[], gmx::ArrayRef<MoleculePatchDatabase> globalPatches,
bool bAllowMissing)
{
t_param *ang, *dih, *pai, *improper;
struct t_excls;
struct MoleculePatchDatabase;
struct t_nextnb;
-struct t_params;
+struct InteractionTypeParameters;
struct PreprocessResidue;
void generate_excls(t_nextnb *nnb, int nrexcl, t_excls excls[]);
void clean_excls(t_nextnb *nnb, int nrexcl, t_excls excls[]);
-void gen_pad(t_nextnb *nnb, t_atoms *atoms, gmx::ArrayRef<const PreprocessResidue> rtpFFDB,
- t_params plist[], t_excls excls[], gmx::ArrayRef<MoleculePatchDatabase> globalPatches,
- bool bAllowMissing);
+void gen_pad(t_nextnb *nnb,
+ t_atoms *atoms,
+ gmx::ArrayRef<const PreprocessResidue> rtpFFDB,
+ gmx::ArrayRef<InteractionTypeParameters> plist,
+ t_excls excls[],
+ gmx::ArrayRef<MoleculePatchDatabase> globalPatches,
+ bool bAllowMissing);
#endif
}
-static void count_bonds(int atom, t_params *psb, char ***atomname,
+static void count_bonds(int atom, InteractionTypeParameters *psb, char ***atomname,
int *nrbonds, int *nrHatoms, int Hatoms[], int *Heavy,
int *nrheavies, int heavies[])
{
- int i, heavy, other, nrb, nrH, nrhv;
+ int heavy, other, nrb, nrH, nrhv;
/* find heavy atom bound to this hydrogen */
heavy = NOTSET;
- for (i = 0; (i < psb->nr) && (heavy == NOTSET); i++)
+ for (int i = 0; (i < psb->nr) && (heavy == NOTSET); i++)
{
if (psb->param[i].ai() == atom)
{
nrb = 0;
nrH = 0;
nrhv = 0;
- for (i = 0; i < psb->nr; i++)
+ for (int i = 0; i < psb->nr; i++)
{
if (psb->param[i].ai() == heavy)
{
return mass;
}
-static void my_add_param(t_params *plist, int ai, int aj, real b)
+static void my_add_param(InteractionTypeParameters *plist, int ai, int aj, real b)
{
static real c[MAXFORCEPARAM] =
{ NOTSET, NOTSET, NOTSET, NOTSET, NOTSET, NOTSET };
add_param(plist, ai, aj, c, nullptr);
}
-static void add_vsites(t_params plist[], int vsite_type[],
+static void add_vsites(gmx::ArrayRef<InteractionTypeParameters> plist, int vsite_type[],
int Heavy, int nrHatoms, int Hatoms[],
int nrheavies, int heavies[])
{
- int i, j, ftype, other, moreheavy;
- bool bSwapParity;
+ int other, moreheavy;
- for (i = 0; i < nrHatoms; i++)
+ for (int i = 0; i < nrHatoms; i++)
{
- ftype = vsite_type[Hatoms[i]];
+ int ftype = vsite_type[Hatoms[i]];
/* Errors in setting the vsite_type should really be caugth earlier,
* because here it's not possible to print any useful error message.
* But it's still better to print a message than to segfault.
{
gmx_incons("Undetected error in setting up virtual sites");
}
- bSwapParity = (ftype < 0);
+ bool bSwapParity = (ftype < 0);
vsite_type[Hatoms[i]] = ftype = abs(ftype);
if (ftype == F_BONDS)
{
{
/* find more heavy atoms */
other = moreheavy = NOTSET;
- for (j = 0; (j < plist[F_BONDS].nr) && (moreheavy == NOTSET); j++)
+ for (int j = 0; (j < plist[F_BONDS].nr) && (moreheavy == NOTSET); j++)
{
if (plist[F_BONDS].param[j].ai() == heavies[0])
{
/* get cos(alpha) when a, b and c are given: */
#define acosrule(a, b, c) ( (gmx::square(b)+gmx::square(c)-gmx::square(a))/(2*(b)*(c)) )
-static int gen_vsites_6ring(t_atoms *at, int *vsite_type[], t_params plist[],
+static int gen_vsites_6ring(t_atoms *at, int *vsite_type[], gmx::ArrayRef<InteractionTypeParameters> plist,
int nrfound, int *ats, real bond_cc, real bond_ch,
real xcom, bool bDoZ)
{
return nvsite;
}
-static int gen_vsites_phe(t_atoms *at, int *vsite_type[], t_params plist[],
+static int gen_vsites_phe(t_atoms *at, int *vsite_type[], gmx::ArrayRef<InteractionTypeParameters> plist,
int nrfound, int *ats, gmx::ArrayRef<const VirtualSiteTopology> vsitetop)
{
real bond_cc, bond_ch;
int *o2n[], int *newvsite_type[], int *newcgnr[],
t_symtab *symtab, int *nadd,
gmx::ArrayRef<const gmx::RVec> x, int *cgnr[],
- t_atoms *at, int *vsite_type[], t_params plist[],
+ t_atoms *at, int *vsite_type[],
+ gmx::ArrayRef<InteractionTypeParameters> plist,
int nrfound, int *ats, int add_shift,
gmx::ArrayRef<const VirtualSiteTopology> vsitetop)
{
int *o2n[], int *newvsite_type[], int *newcgnr[],
t_symtab *symtab, int *nadd,
gmx::ArrayRef<const gmx::RVec> x, int *cgnr[],
- t_atoms *at, int *vsite_type[], t_params plist[],
+ t_atoms *at, int *vsite_type[],
+ gmx::ArrayRef<InteractionTypeParameters> plist,
int nrfound, int *ats, int add_shift,
gmx::ArrayRef<const VirtualSiteTopology> vsitetop)
{
return nvsite;
}
-static int gen_vsites_his(t_atoms *at, int *vsite_type[], t_params plist[],
+static int gen_vsites_his(t_atoms *at, int *vsite_type[],
+ gmx::ArrayRef<InteractionTypeParameters> plist,
int nrfound, int *ats, gmx::ArrayRef<const VirtualSiteTopology> vsitetop)
{
int nvsite, i;
void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *atype,
t_atoms *at, t_symtab *symtab,
std::vector<gmx::RVec> *x,
- t_params plist[], int *vsite_type[], int *cgnr[],
+ gmx::ArrayRef<InteractionTypeParameters> plist, int *vsite_type[], int *cgnr[],
real mHmult, bool bVsiteAromatics,
const char *ffdir)
{
#define MAXATOMSPERRESIDUE 16
- int i, j, k, m, i0, ni0, whatres, resind, add_shift, ftype, nvsite, nadd;
- int ai, aj, ak, al;
- int nrfound = 0, needed, nrbonds, nrHatoms, Heavy, nrheavies, tpM, tpHeavy;
- int Hatoms[4], heavies[4];
- bool bWARNING, bAddVsiteParam, bFirstWater;
- matrix tmpmat;
- real mHtot, mtot, fact, fact2;
- rvec rpar, rperp, temp;
- char tpname[32], nexttpname[32];
- int *o2n, *newvsite_type, *newcgnr, ats[MAXATOMSPERRESIDUE];
- t_atom *newatom;
- t_params *params;
- char ***newatomname;
- char *resnm = nullptr;
- int cmplength;
- bool isN, planarN, bFound;
+ int k, m, i0, ni0, whatres, resind, add_shift, nvsite, nadd;
+ int ai, aj, ak, al;
+ int nrfound = 0, needed, nrbonds, nrHatoms, Heavy, nrheavies, tpM, tpHeavy;
+ int Hatoms[4], heavies[4];
+ bool bWARNING, bAddVsiteParam, bFirstWater;
+ matrix tmpmat;
+ real mHtot, mtot, fact, fact2;
+ rvec rpar, rperp, temp;
+ char tpname[32], nexttpname[32];
+ int *o2n, *newvsite_type, *newcgnr, ats[MAXATOMSPERRESIDUE];
+ t_atom *newatom;
+ InteractionTypeParameters *params;
+ char ***newatomname;
+ char *resnm = nullptr;
+ int cmplength;
+ bool isN, planarN, bFound;
/* if bVsiteAromatics=TRUE do_vsites will specifically convert atoms in
PHE, TRP, TYR and HIS to a construction of virtual sites */
snew(newcgnr, at->nr);
/* make index array to tell where the atoms go to when masses are inserted */
snew(o2n, at->nr);
- for (i = 0; i < at->nr; i++)
+ for (int i = 0; i < at->nr; i++)
{
o2n[i] = i;
}
/* generate vsite constructions */
/* loop over all atoms */
resind = -1;
- for (i = 0; (i < at->nr); i++)
+ for (int i = 0; (i < at->nr); i++)
{
if (at->atom[i].resind != resind)
{
bResProcessed[resind] = TRUE;
/* find out if this residue needs converting */
whatres = NOTSET;
- for (j = 0; j < resNR && whatres == NOTSET; j++)
+ for (int j = 0; j < resNR && whatres == NOTSET; j++)
{
cmplength = bPartial[j] ? strlen(resnm)-1 : strlen(resnm);
if ((nrHatoms == 2) && ((*at->atomname[Heavy])[0] == 'N'))
{
isN = TRUE;
- j = nitrogen_is_planar(vsiteconflist, tpname);
+ int j = nitrogen_is_planar(vsiteconflist, tpname);
if (j < 0)
{
gmx_fatal(FARGS, "No vsite database NH2 entry for type %s\n", tpname);
bAddVsiteParam = FALSE; /* we'll do this ourselves! */
/* -NH2 (umbrella), -NH3+ or -CH3 */
(*vsite_type)[Heavy] = F_VSITE3;
- for (j = 0; j < nrHatoms; j++)
+ for (int j = 0; j < nrHatoms; j++)
{
(*vsite_type)[Hatoms[j]] = Hat_vsite_type[j];
}
fprintf(stderr, "Inserting %d dummy masses at %d\n", NMASS, o2n[i0]+1);
}
nadd += NMASS;
- for (j = i0; j < at->nr; j++)
+ for (int j = i0; j < at->nr; j++)
{
o2n[j] = j+nadd;
}
srenew(newvsite_type, at->nr+nadd);
srenew(newcgnr, at->nr+nadd);
- for (j = 0; j < NMASS; j++)
+ for (int j = 0; j < NMASS; j++)
{
newatomname[at->nr+nadd-1-j] = nullptr;
}
/* calculate starting position for the masses */
mHtot = 0;
/* get atom masses, and set Heavy and Hatoms mass to zero */
- for (j = 0; j < nrHatoms; j++)
+ for (int j = 0; j < nrHatoms; j++)
{
mHtot += get_amass(Hatoms[j], at, rtpFFDB, &rt);
at->atom[Hatoms[j]].m = at->atom[Hatoms[j]].mB = 0;
* rpar = Heavy -> Hcom
* rperp = Hcom -> H1 */
clear_rvec(rpar);
- for (j = 0; j < nrHatoms; j++)
+ for (int j = 0; j < nrHatoms; j++)
{
rvec_inc(rpar, (*x)[Hatoms[j]]);
}
rvec_dec(rperp, rpar); /* rperp = H1 - Heavy - rpar */
/* calc mass positions */
svmul(fact2, rpar, temp);
- for (j = 0; (j < NMASS); j++) /* xM = xN + fact2 * rpar +/- fact * rperp */
+ for (int j = 0; (j < NMASS); j++) /* xM = xN + fact2 * rpar +/- fact * rperp */
{
rvec_add((*x)[Heavy], temp, newx[ni0+j]);
}
rvec_inc(newx[ni0 ], temp);
rvec_dec(newx[ni0+1], temp);
/* set atom parameters for the masses */
- for (j = 0; (j < NMASS); j++)
+ for (int j = 0; (j < NMASS); j++)
{
/* make name: "M??#" or "M?#" (? is atomname, # is number) */
name[0] = 'M';
+ int k;
for (k = 0; (*at->atomname[Heavy])[k] && ( k < NMASS ); k++)
{
name[k+1] = (*at->atomname[Heavy])[k];
add_vsite3_atoms (&plist[(*vsite_type)[Heavy]],
Heavy, heavies[0], add_shift+ni0, add_shift+ni0+1,
FALSE);
- for (j = 0; j < nrHatoms; j++)
+ for (int j = 0; j < nrHatoms; j++)
{
add_vsite3_atoms(&plist[(*vsite_type)[Hatoms[j]]],
Hatoms[j], heavies[0], add_shift+ni0, add_shift+ni0+1,
add_vsites(plist, (*vsite_type), Heavy, nrHatoms, Hatoms,
nrheavies, heavies);
/* transfer mass of virtual site to Heavy atom */
- for (j = 0; j < nrHatoms; j++)
+ for (int j = 0; j < nrHatoms; j++)
{
if (is_vsite((*vsite_type)[Hatoms[j]]))
{
if (debug)
{
fprintf(debug, "Before inserting new atoms:\n");
- for (i = 0; i < at->nr; i++)
+ for (int i = 0; i < at->nr; i++)
{
fprintf(debug, "%4d %4d %4s %4d %4s %6d %-10s\n", i+1, o2n[i]+1,
at->atomname[i] ? *(at->atomname[i]) : "(NULL)",
"NOTSET" : interaction_function[(*vsite_type)[i]].name);
}
fprintf(debug, "new atoms to be inserted:\n");
- for (i = 0; i < at->nr+nadd; i++)
+ for (int i = 0; i < at->nr+nadd; i++)
{
if (newatomname[i])
{
}
/* add all original atoms to the new arrays, using o2n index array */
- for (i = 0; i < at->nr; i++)
+ for (int i = 0; i < at->nr; i++)
{
newatomname [o2n[i]] = at->atomname [i];
newatom [o2n[i]] = at->atom [i];
if (debug)
{
fprintf(debug, "After inserting new atoms:\n");
- for (i = 0; i < at->nr; i++)
+ for (int i = 0; i < at->nr; i++)
{
fprintf(debug, "%4d %4s %4d %4s %6d %-10s\n", i+1,
at->atomname[i] ? *(at->atomname[i]) : "(NULL)",
}
/* now renumber all the interactions because of the added atoms */
- for (ftype = 0; ftype < F_NRE; ftype++)
+ for (int ftype = 0; ftype < F_NRE; ftype++)
{
- params = &(plist[ftype]);
+ InteractionTypeParameters *params = &(plist[ftype]);
if (debug)
{
fprintf(debug, "Renumbering %d %s\n", params->nr,
interaction_function[ftype].longname);
}
- for (i = 0; i < params->nr; i++)
+ for (int i = 0; i < params->nr; i++)
{
- for (j = 0; j < NRAL(ftype); j++)
+ for (int j = 0; j < NRAL(ftype); j++)
{
if (params->param[i].a[j] >= add_shift)
{
}
/* now check if atoms in the added constraints are in increasing order */
params = &(plist[F_CONSTRNC]);
- for (i = 0; i < params->nr; i++)
+ for (int i = 0; i < params->nr; i++)
{
if (params->param[i].ai() > params->param[i].aj())
{
- j = params->param[i].aj();
+ int j = params->param[i].aj();
params->param[i].aj() = params->param[i].ai();
params->param[i].ai() = j;
}
fprintf(stderr, "Added %d new constraints\n", plist[F_CONSTRNC].nr);
}
-void do_h_mass(t_params *psb, int vsite_type[], t_atoms *at, real mHmult,
+void do_h_mass(InteractionTypeParameters *psb, int vsite_type[], t_atoms *at, real mHmult,
bool bDeuterate)
{
- int i, j, a;
-
/* loop over all atoms */
- for (i = 0; i < at->nr; i++)
+ for (int i = 0; i < at->nr; i++)
{
/* adjust masses if i is hydrogen and not a virtual site */
if (!is_vsite(vsite_type[i]) && is_hydrogen(*(at->atomname[i])) )
{
/* find bonded heavy atom */
- a = NOTSET;
- for (j = 0; (j < psb->nr) && (a == NOTSET); j++)
+ int a = NOTSET;
+ for (int j = 0; (j < psb->nr) && (a == NOTSET); j++)
{
/* if other atom is not a virtual site, it is the one we want */
if ( (psb->param[j].ai() == i) &&
struct gpp_atomtype;
struct t_atoms;
-struct t_params;
+struct InteractionTypeParameters;
struct PreprocessResidue;
struct t_symtab;
void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *atype,
t_atoms *at, t_symtab *symtab, std::vector<gmx::RVec> *x,
- t_params plist[], int *dummy_type[], int *cgnr[],
+ gmx::ArrayRef<InteractionTypeParameters> plist, int *dummy_type[], int *cgnr[],
real mHmult, bool bVSiteAromatics,
const char *ffdir);
-void do_h_mass(t_params *psb, int vsite_type[], t_atoms *at, real mHmult,
+void do_h_mass(InteractionTypeParameters *psb, int vsite_type[], t_atoms *at, real mHmult,
bool bDeuterate);
#endif
return i;
}
-void renum_atype(t_params plist[], gmx_mtop_t *mtop,
+void renum_atype(gmx::ArrayRef<InteractionTypeParameters> plist, gmx_mtop_t *mtop,
int *wall_atomtype,
gpp_atomtype *ga, bool bVerbose)
{
#include <cstdio>
+#include "gromacs/utility/arrayref.h"
#include "gromacs/utility/real.h"
struct gmx_mtop_t;
struct t_atom;
struct t_atomtypes;
struct t_param;
-struct t_params;
+struct InteractionTypeParameters;
struct t_symtab;
int get_atomtype_type(const char *str, gpp_atomtype *at);
void print_at (FILE * out, gpp_atomtype *at);
/* Print an atomtype record to a text file */
-void renum_atype(t_params plist[], gmx_mtop_t *mtop,
+void renum_atype(gmx::ArrayRef<InteractionTypeParameters> plist, gmx_mtop_t *mtop,
int *wall_atomtype,
gpp_atomtype *at, bool bVerbose);
}
-static void add_b(t_params *bonds, int *nrf, sortable *s)
+static void add_b(InteractionTypeParameters *bonds, int *nrf, sortable *s)
{
- int i;
- int ai, aj;
-
- for (i = 0; (i < bonds->nr); i++)
+ for (int i = 0; (i < bonds->nr); i++)
{
- ai = bonds->param[i].ai();
- aj = bonds->param[i].aj();
+ int ai = bonds->param[i].ai();
+ int aj = bonds->param[i].aj();
if ((ai < 0) || (aj < 0))
{
gmx_fatal(FARGS, "Impossible atom numbers in bond %d: ai=%d, aj=%d",
}
}
-void gen_nnb(t_nextnb *nnb, t_params plist[])
+void gen_nnb(t_nextnb *nnb, gmx::ArrayRef<InteractionTypeParameters> plist)
{
sortable *s;
- int i, nrbonds, nrf;
+ int nrbonds, nrf;
nrbonds = 0;
- for (i = 0; (i < F_NRE); i++)
+ for (int i = 0; (i < F_NRE); i++)
{
if (IS_CHEMBOND(i))
{
snew(s, nrbonds);
nrf = 0;
- for (i = 0; (i < F_NRE); i++)
+ for (int i = 0; (i < F_NRE); i++)
{
if (IS_CHEMBOND(i))
{
}
-void generate_excl (int nrexcl, int nratoms, t_params plist[], t_nextnb *nnb, t_blocka *excl)
+void generate_excl (int nrexcl,
+ int nratoms,
+ gmx::ArrayRef<InteractionTypeParameters> plist, t_nextnb *nnb, t_blocka *excl)
{
if (nrexcl < 0)
{
#ifndef GMX_GMXPREPROCESS_GPP_NEXTNB_H
#define GMX_GMXPREPROCESS_GPP_NEXTNB_H
+#include "gromacs/utility/arrayref.h"
+
struct t_blocka;
-struct t_params;
+struct InteractionTypeParameters;
struct t_nextnb
{
#define print_nnb(nnb, s)
#endif
-void gen_nnb(t_nextnb *nnb, t_params plist[]);
+void gen_nnb(t_nextnb *nnb, gmx::ArrayRef<InteractionTypeParameters> plist);
/* Generate a t_nextnb structure from bond information.
* With the structure you can either generate exclusions
* or generate angles and dihedrals. The structure must be
*/
void generate_excl (int nrexcl, int nratoms,
- t_params plist[], t_nextnb *nnb, t_blocka *excl);
+ gmx::ArrayRef<InteractionTypeParameters> plist, t_nextnb *nnb, t_blocka *excl);
/* Generate an exclusion block from bonds and constraints in
* plist.
*/
gpp_atomtype *atype, gmx_mtop_t *sys,
std::vector<MoleculeInformation> *mi,
std::unique_ptr<MoleculeInformation> *intermolecular_interactions,
- t_params plist[],
+ gmx::ArrayRef<InteractionTypeParameters> plist,
int *comb, double *reppow, real *fudgeQQ,
gmx_bool bMorse,
warninp *wi)
for (gmx_molblock_t &molb : mtop->molblock)
{
nat_molb = molb.nmol*mtop->moltype[molb.type].atoms.nr;
- const t_params *pr = &(molinfo[molb.type].plist[F_POSRES]);
- const t_params *prfb = &(molinfo[molb.type].plist[F_FBPOSRES]);
+ const InteractionTypeParameters *pr = &(molinfo[molb.type].plist[F_POSRES]);
+ const InteractionTypeParameters *prfb = &(molinfo[molb.type].plist[F_FBPOSRES]);
if (pr->nr > 0 || prfb->nr > 0)
{
atom = mtop->moltype[molb.type].atoms.atom;
static void
-setup_cmap (int grid_spacing,
- int nc,
- const real * grid,
- gmx_cmap_t * cmap_grid)
+setup_cmap (int grid_spacing,
+ int nc,
+ gmx::ArrayRef<const real> grid,
+ gmx_cmap_t * cmap_grid)
{
int i, j, k, ii, jj, kk, idx;
int offset;
for (const gmx_molblock_t &molb : mtop->molblock)
{
count_mol = 0;
- const t_params *plist = mi[molb.type].plist;
+ gmx::ArrayRef<const InteractionTypeParameters> plist = mi[molb.type].plist;
for (i = 0; i < F_NRE; i++)
{
std::unique_ptr<MoleculeInformation> intermolecular_interactions;
gpp_atomtype *atype;
int nvsite, comb;
- t_params *plist;
real fudgeQQ;
double reppow;
const char *mdparin;
warning_error(wi, warn_buf);
}
- snew(plist, F_NRE);
+ std::array<InteractionTypeParameters, F_NRE> plist;
init_plist(plist);
gmx_mtop_t sys;
atype = init_atomtype();
}
/* If we are using CMAP, setup the pre-interpolation grid */
- if (plist[F_CMAP].ncmap > 0)
+ if (plist[F_CMAP].ncmap() > 0)
{
- init_cmap_grid(&sys.ffparams.cmap_grid, plist[F_CMAP].nc, plist[F_CMAP].grid_spacing);
- setup_cmap(plist[F_CMAP].grid_spacing, plist[F_CMAP].nc, plist[F_CMAP].cmap, &sys.ffparams.cmap_grid);
+ init_cmap_grid(&sys.ffparams.cmap_grid, plist[F_CMAP].cmapAngles, plist[F_CMAP].cmakeGridSpacing);
+ setup_cmap(plist[F_CMAP].cmakeGridSpacing, plist[F_CMAP].cmapAngles, plist[F_CMAP].cmap, &sys.ffparams.cmap_grid);
}
set_wall_atomtype(atype, opts, ir, wi);
}
ntype = get_atomtype_ntypes(atype);
- convert_params(ntype, plist, mi, intermolecular_interactions.get(),
- comb, reppow, fudgeQQ, &sys);
+ convertInteractionTypeParameters(ntype, plist, mi, intermolecular_interactions.get(),
+ comb, reppow, fudgeQQ, &sys);
if (debug)
{
- pr_symtab(debug, 0, "After convert_params", &sys.symtab);
+ pr_symtab(debug, 0, "After converInteractionTypeParameters", &sys.symtab);
}
/* set ptype to VSite for virtual sites */
sfree(opts->include);
sfree(opts);
done_plist(plist);
- sfree(plist);
for (auto &mol : mi)
{
// Some of the contents of molinfo have been stolen, so
struct t_param
{
- int a[MAXATOMLIST]; /* The atom list (eg. bonds: particle */
- /* i = a[0] (ai), j = a[1] (aj)) */
- real c[MAXFORCEPARAM]; /* Force parameters (eg. b0 = c[0]) */
- char s[MAXSLEN]; /* A string (instead of parameters), *
- * read from the .rtp file in pdb2gmx */
- const int &ai() const { return a[0]; }
- int &ai() { return a[0]; }
- const int &aj() const { return a[1]; }
- int &aj() { return a[1]; }
- const int &ak() const { return a[2]; }
- int &ak() { return a[2]; }
- const int &al() const { return a[3]; }
- int &al() { return a[3]; }
- const int &am() const { return a[4]; }
- int &am() { return a[4]; }
-
- real &c0() { return c[0]; }
- real &c1() { return c[1]; }
- real &c2() { return c[2]; }
+ int a[MAXATOMLIST]; /* The atom list (eg. bonds: particle */
+ /* i = a[0] (ai), j = a[1] (aj)) */
+ real c[MAXFORCEPARAM]; /* Force parameters (eg. b0 = c[0]) */
+ char s[MAXSLEN]; /* A string (instead of parameters), *
+ * read from the .rtp file in pdb2gmx */
+ const int &ai() const { return a[0]; }
+ int &ai() { return a[0]; }
+ const int &aj() const { return a[1]; }
+ int &aj() { return a[1]; }
+ const int &ak() const { return a[2]; }
+ int &ak() { return a[2]; }
+ const int &al() const { return a[3]; }
+ int &al() { return a[3]; }
+ const int &am() const { return a[4]; }
+ int &am() { return a[4]; }
+
+ const real &c0() const { return c[0]; }
+ real &c0() { return c[0]; }
+ const real &c1() const { return c[1]; }
+ real &c1() { return c[1]; }
+ const real &c2() const { return c[2]; }
+ real &c2() { return c[2]; }
};
-struct t_params
+/*! \libinternal \brief
+ * The parameters for a set of interactions of a given
+ * (unspecified) type found in the enumeration in ifunc.h.
+ *
+ * This is used for containing the data obtained from the
+ * lists of interactions of a given type in a [moleculetype]
+ * topology file definition.
+ *
+ * \todo Remove manual memory management.
+ */
+struct InteractionTypeParameters
{ // NOLINT (clang-analyzer-optin.performance.Padding)
- int nr; /* The number of bonds in this record */
- int maxnr; /* The amount of elements in the array */
- t_param *param; /* Array of parameters (dim: nr or nr*nr) */
-
- /* CMAP tmp data, there are probably better places for this */
- int grid_spacing; /* Cmap grid spacing */
- int nc; /* Number of cmap angles */
-
- real *cmap; /* Temporary storage of the raw cmap grid data */
- int ncmap; /* Number of allocated elements in cmap grid*/
-
- int *cmap_types; /* Store the five atomtypes followed by a number that identifies the type */
- int nct; /* Number of allocated elements in cmap_types */
+ //! Number of parameters.
+ int nr = 0;
+ //! Maximum number of parameters.
+ int maxnr = 0;
+ //! The parameters of the interactions
+ t_param *param;
+ //! CMAP grid spacing.
+ int cmakeGridSpacing = -1;
+ //! Number of cmap angles.
+ int cmapAngles = -1;
+ //! CMAP grid data.
+ std::vector<real> cmap;
+ //! The five atomtypes followed by a number that identifies the type.
+ std::vector<int> cmapAtomTypes;
+
+ //! Elements in cmap grid data.
+ int ncmap() const { return cmap.size(); }
+ //! Number of elements in cmapAtomTypes.
+ int nct() const { return cmapAtomTypes.size(); }
};
struct t_excls
struct MoleculeInformation
{
//! Name of the molecule.
- char **name = nullptr;
+ char **name = nullptr;
//!Number of exclusions per atom.
- int nrexcl = 0;
+ int nrexcl = 0;
//! Have exclusions been generated?.
- bool excl_set = false;
+ bool excl_set = false;
//! Has the mol been processed.
- bool bProcessed = false;
+ bool bProcessed = false;
//! Atoms in the moelcule.
- t_atoms atoms;
+ t_atoms atoms;
//! Charge groups in the molecule
- t_block cgs;
+ t_block cgs;
//! Molecules separated in datastructure.
- t_block mols;
+ t_block mols;
//! Exclusions in the molecule.
- t_blocka excls;
+ t_blocka excls;
//! Parameters in old style.
- t_params plist[F_NRE];
+ std::array<InteractionTypeParameters, F_NRE> plist;
/*! \brief
* Initializer.
}
int nm2type(int nnm, t_nm2type nm2t[], t_symtab *tab, t_atoms *atoms,
- gpp_atomtype *atype, int *nbonds, t_params *bonds)
+ gpp_atomtype *atype, int *nbonds, InteractionTypeParameters *bonds)
{
int cur = 0;
#define prev (1-cur)
struct gpp_atomtype;
struct t_atoms;
-struct t_params;
+struct InteractionTypeParameters;
struct t_symtab;
struct t_nm2type
/* Dump the database for debugging. Can be reread by the program */
int nm2type(int nnm, t_nm2type nm2t[], t_symtab *tab, t_atoms *atoms,
- gpp_atomtype *atype, int *nbonds, t_params *bond);
+ gpp_atomtype *atype, int *nbonds, InteractionTypeParameters *bond);
/* Try to determine the atomtype (force field dependent) for the atoms
* with help of the bond list
*/
void write_top(FILE *out, const char *pr, const char *molname,
t_atoms *at, bool bRTPresname,
- int bts[], t_params plist[], t_excls excls[],
+ int bts[], gmx::ArrayRef<const InteractionTypeParameters> plist, t_excls excls[],
gpp_atomtype *atype, int *cgnr, int nrexcl)
/* NOTE: nrexcl is not the size of *excl! */
{
-static void do_ssbonds(t_params *ps, t_atoms *atoms,
+static void do_ssbonds(InteractionTypeParameters *ps, t_atoms *atoms,
gmx::ArrayRef<const DisulfideBond> ssbonds, bool bAllowMissing)
{
for (const auto &bond : ssbonds)
}
}
-static void at2bonds(t_params *psb, gmx::ArrayRef<MoleculePatchDatabase> globalPatches,
+static void at2bonds(InteractionTypeParameters *psb, gmx::ArrayRef<MoleculePatchDatabase> globalPatches,
t_atoms *atoms,
gmx::ArrayRef<const gmx::RVec> x,
real long_bond_dist, real short_bond_dist)
}
}
-static void clean_bonds(t_params *ps)
+static void clean_bonds(InteractionTypeParameters *ps)
{
int i, j;
int a;
}
}
-void print_sums(t_atoms *atoms, bool bSystem)
+void print_sums(const t_atoms *atoms, bool bSystem)
{
double m, qtot;
int i;
}
#define NUM_CMAP_ATOMS 5
-static void gen_cmap(t_params *psb, gmx::ArrayRef<const PreprocessResidue> usedPpResidues, t_atoms *atoms)
+static void gen_cmap(InteractionTypeParameters *psb, gmx::ArrayRef<const PreprocessResidue> usedPpResidues, t_atoms *atoms)
{
int residx;
const char *ptr;
bool bDeuterate, bool bChargeGroups, bool bCmap,
bool bRenumRes, bool bRTPresname)
{
- t_params plist[F_NRE];
- t_excls *excls;
- t_nextnb nnb;
- int *cgnr;
- int *vsite_type;
- int i, nmissat;
- int bts[ebtsNR];
+ std::array<InteractionTypeParameters, F_NRE> plist;
+ t_excls *excls;
+ t_nextnb nnb;
+ int *cgnr;
+ int *vsite_type;
+ int i, nmissat;
+ int bts[ebtsNR];
init_plist(plist);
ResidueType rt;
struct t_excls;
struct MoleculePatchDatabase;
struct t_mols;
-struct t_params;
+struct InteractionTypeParameters;
struct t_resinfo;
struct PreprocessResidue;
struct DisulfideBond;
void write_top(FILE *out, const char *pr, const char *molname,
t_atoms *at, bool bRTPresname,
- int bts[], t_params plist[], t_excls excls[],
+ int bts[], gmx::ArrayRef<const InteractionTypeParameters> plist, t_excls excls[],
gpp_atomtype *atype, int *cgnr, int nrexcl);
/* NOTE: nrexcl is not the size of *excl! */
bool bRenumRes, bool bRTPresname);
/* Create a topology ! */
-void print_sums(t_atoms *atoms, bool bSystem);
+void print_sums(const t_atoms *atoms, bool bSystem);
#endif
#define OPENDIR '[' /* starting sign for directive */
#define CLOSEDIR ']' /* ending sign for directive */
-static void gen_pairs(t_params *nbs, t_params *pairs, real fudge, int comb)
+static void gen_pairs(InteractionTypeParameters *nbs, InteractionTypeParameters *pairs, real fudge, int comb)
{
int i, j, ntp, nrfp, nrfpA, nrfpB, nnn;
real scaling;
int *nrmols,
std::vector<MoleculeInformation> *molinfo,
std::unique_ptr<MoleculeInformation> *intermolecular_interactions,
- t_params plist[],
+ gmx::ArrayRef<InteractionTypeParameters> plist,
int *combination_rule,
double *reppow,
t_gromppopts *opts,
*reppow = 12.0; /* Default value for repulsion power */
/* Init the number of CMAP torsion angles and grid spacing */
- plist[F_CMAP].grid_spacing = 0;
- plist[F_CMAP].nc = 0;
+ plist[F_CMAP].cmakeGridSpacing = 0;
+ plist[F_CMAP].cmapAngles = 0;
bWarn_copy_A_B = bFEP;
break;
case Directive::d_pairs:
+ GMX_RELEASE_ASSERT(mi0, "Need to have a valid MoleculeInformation object to work on");
push_bond(d, plist, mi0->plist, &(mi0->atoms), atype, pline, FALSE,
bGenPairs, *fudgeQQ, bZero, &bWarn_copy_A_B, wi);
break;
case Directive::d_pairs_nb:
+ GMX_RELEASE_ASSERT(mi0, "Need to have a valid MoleculeInformation object to work on");
push_bond(d, plist, mi0->plist, &(mi0->atoms), atype, pline, FALSE,
FALSE, 1.0, bZero, &bWarn_copy_A_B, wi);
break;
case Directive::d_polarization:
case Directive::d_water_polarization:
case Directive::d_thole_polarization:
+ GMX_RELEASE_ASSERT(mi0, "Need to have a valid MoleculeInformation object to work on");
push_bond(d, plist, mi0->plist, &(mi0->atoms), atype, pline, TRUE,
bGenPairs, *fudgeQQ, bZero, &bWarn_copy_A_B, wi);
break;
case Directive::d_cmap:
+ GMX_RELEASE_ASSERT(mi0, "Need to have a valid MoleculeInformation object to work on");
push_cmap(d, plist, mi0->plist, &(mi0->atoms), atype, pline, wi);
break;
case Directive::d_vsitesn:
+ GMX_RELEASE_ASSERT(mi0, "Need to have a valid MoleculeInformation object to work on");
push_vsitesn(d, mi0->plist, &(mi0->atoms), pline, wi);
break;
case Directive::d_exclusions:
return title;
}
-char **do_top(bool bVerbose,
- const char *topfile,
- const char *topppfile,
- t_gromppopts *opts,
- bool bZero,
- t_symtab *symtab,
- t_params plist[],
- int *combination_rule,
- double *repulsion_power,
- real *fudgeQQ,
- gpp_atomtype *atype,
- int *nrmols,
- std::vector<MoleculeInformation> *molinfo,
- std::unique_ptr<MoleculeInformation> *intermolecular_interactions,
- const t_inputrec *ir,
- std::vector<gmx_molblock_t> *molblock,
- bool *ffParametrizedWithHBondConstraints,
- warninp *wi)
+char **do_top(bool bVerbose,
+ const char *topfile,
+ const char *topppfile,
+ t_gromppopts *opts,
+ bool bZero,
+ t_symtab *symtab,
+ gmx::ArrayRef<InteractionTypeParameters> plist,
+ int *combination_rule,
+ double *repulsion_power,
+ real *fudgeQQ,
+ gpp_atomtype *atype,
+ int *nrmols,
+ std::vector<MoleculeInformation> *molinfo,
+ std::unique_ptr<MoleculeInformation> *intermolecular_interactions,
+ const t_inputrec *ir,
+ std::vector<gmx_molblock_t> *molblock,
+ bool *ffParametrizedWithHBondConstraints,
+ warninp *wi)
{
/* Tmpfile might contain a long path */
const char *tmpfile;
#include <memory>
#include <vector>
+#include "gromacs/utility/arrayref.h"
#include "gromacs/utility/real.h"
struct gmx_molblock_t;
struct t_gromppopts;
struct t_inputrec;
struct MoleculeInformation;
-struct t_params;
+struct InteractionTypeParameters;
struct t_symtab;
struct warninp;
enum struct GmxQmmmMode;
double check_mol(const gmx_mtop_t *mtop, warninp_t wi);
/* Check mass and charge */
-char **do_top(bool bVerbose,
- const char *topfile,
- const char *topppfile,
- t_gromppopts *opts,
- bool bZero,
- t_symtab *symtab,
- t_params plist[],
- int *combination_rule,
- double *repulsion_power,
- real *fudgeQQ,
- gpp_atomtype *atype,
- int *nrmols,
- std::vector<MoleculeInformation> *molinfo,
- std::unique_ptr<MoleculeInformation> *intermolecular_interactions,
- const t_inputrec *ir,
- std::vector<gmx_molblock_t> *molblock,
- bool *ffParametrizedWithHBondConstraints,
- warninp_t wi);
+char **do_top(bool bVerbose,
+ const char *topfile,
+ const char *topppfile,
+ t_gromppopts *opts,
+ bool bZero,
+ t_symtab *symtab,
+ gmx::ArrayRef<InteractionTypeParameters> plist,
+ int *combination_rule,
+ double *repulsion_power,
+ real *fudgeQQ,
+ gpp_atomtype *atype,
+ int *nrmols,
+ std::vector<MoleculeInformation> *molinfo,
+ std::unique_ptr<MoleculeInformation> *intermolecular_interactions,
+ const t_inputrec *ir,
+ std::vector<gmx_molblock_t> *molblock,
+ bool *ffParametrizedWithHBondConstraints,
+ warninp_t wi);
/* This routine expects sys->molt[m].ilist to be of size F_NRE and ordered. */
void generate_qmexcl(gmx_mtop_t *sys, t_inputrec *ir, warninp_t wi, GmxQmmmMode qmmmMode);
#include "gromacs/utility/smalloc.h"
#include "gromacs/utility/stringutil.h"
-void generate_nbparams(int comb, int ftype, t_params *plist, gpp_atomtype *atype,
+void generate_nbparams(int comb, int ftype, InteractionTypeParameters *plist, gpp_atomtype *atype,
warninp *wi)
{
int i, j, k = -1, nf;
}
/*! \brief Used to temporarily store the explicit non-bonded parameter
- * combinations, which will be copied to t_params. */
+ * combinations, which will be copied to InteractionTypeParameters. */
struct t_nbparam
{
//! Has this combination been set.
}
}
-int copy_nbparams(t_nbparam **param, int ftype, t_params *plist, int nr)
+int copy_nbparams(t_nbparam **param, int ftype, InteractionTypeParameters *plist, int nr)
{
int i, j, f;
int nrfp, ncopy;
std::equal(a.begin(), a.end(), b.rbegin()));
}
-static void push_bondtype(t_params * bt,
- const t_param * b,
- int nral,
- int ftype,
- bool bAllowRepeat,
- const char * line,
- warninp *wi)
+static void push_bondtype(InteractionTypeParameters * bt,
+ const t_param * b,
+ int nral,
+ int ftype,
+ bool bAllowRepeat,
+ const char * line,
+ warninp *wi)
{
int nr = bt->nr;
int nrfp = NRFP(ftype);
}
}
-void push_bt(Directive d, t_params bt[], int nral,
+void push_bt(Directive d, gmx::ArrayRef<InteractionTypeParameters> bt, int nral,
gpp_atomtype *at,
gpp_bond_atomtype *bat, char *line,
warninp *wi)
}
-void push_dihedraltype(Directive d, t_params bt[],
+void push_dihedraltype(Directive d, gmx::ArrayRef<InteractionTypeParameters> bt,
gpp_bond_atomtype *bat, char *line,
warninp *wi)
{
}
void
-push_cmaptype(Directive d, t_params bt[], int nral, gpp_atomtype *at,
+push_cmaptype(Directive d, gmx::ArrayRef<InteractionTypeParameters> bt, int nral, gpp_atomtype *at,
gpp_bond_atomtype *bat, char *line,
warninp *wi)
{
nrfpB = strtol(alc[7], nullptr, 10)*strtol(alc[7], nullptr, 10);
nrfp = nrfpA+nrfpB;
- /* Allocate memory for the CMAP grid */
- bt[F_CMAP].ncmap += nrfp;
- srenew(bt[F_CMAP].cmap, bt[F_CMAP].ncmap);
-
/* Read in CMAP parameters */
sl = 0;
for (i = 0; i < ncmap; i++)
}
nn = sscanf(line+start+sl, " %s ", s);
sl += strlen(s);
- bt[F_CMAP].cmap[i+(bt[F_CMAP].ncmap)-nrfp] = strtod(s, nullptr);
+ bt[F_CMAP].cmap.emplace_back(strtod(s, nullptr));
if (nn == 1)
{
{
for (i = 0; i < ncmap; i++)
{
- bt[F_CMAP].cmap[i+ncmap] = bt[F_CMAP].cmap[i];
+ bt[F_CMAP].cmap.emplace_back(bt[F_CMAP].cmap[i]);
}
}
else
/* Set grid spacing and the number of grids (we assume these numbers to be the same for all grids
* so we can safely assign them each time
*/
- bt[F_CMAP].grid_spacing = nxcmap; /* Or nycmap, they need to be equal */
- bt[F_CMAP].nc = bt[F_CMAP].nc + 1; /* Since we are incrementing here, we need to subtract later, see (*****) */
- nct = (nral+1) * bt[F_CMAP].nc;
-
- /* Allocate memory for the cmap_types information */
- srenew(bt[F_CMAP].cmap_types, nct);
+ bt[F_CMAP].cmakeGridSpacing = nxcmap; /* Or nycmap, they need to be equal */
+ bt[F_CMAP].cmapAngles++; /* Since we are incrementing here, we need to subtract later, see (*****) */
+ nct = (nral+1) * bt[F_CMAP].cmapAngles;
for (i = 0; (i < nral); i++)
{
}
/* Assign a grid number to each cmap_type */
- bt[F_CMAP].cmap_types[bt[F_CMAP].nct++] = get_bond_atomtype_type(alc[i], bat);
+ bt[F_CMAP].cmapAtomTypes.emplace_back(get_bond_atomtype_type(alc[i], bat));
}
/* Assign a type number to this cmap */
- bt[F_CMAP].cmap_types[bt[F_CMAP].nct++] = bt[F_CMAP].nc-1; /* Since we inremented earlier, we need to subtrac here, to get the types right (****) */
+ bt[F_CMAP].cmapAtomTypes.emplace_back(bt[F_CMAP].cmapAngles-1); /* Since we inremented earlier, we need to subtrac here, to get the types right (****) */
/* Check for the correct number of atoms (again) */
- if (bt[F_CMAP].nct != nct)
+ if (bt[F_CMAP].nct() != nct)
{
- auto message = gmx::formatString("Incorrect number of atom types (%d) in cmap type %d\n", nct, bt[F_CMAP].nc);
+ auto message = gmx::formatString("Incorrect number of atom types (%d) in cmap type %d\n", nct, bt[F_CMAP].cmapAngles);
warning_error(wi, message);
}
mol->back().excl_set = false;
}
-static bool default_nb_params(int ftype, t_params bt[], t_atoms *at,
+static bool default_nb_params(int ftype, gmx::ArrayRef<InteractionTypeParameters> bt, t_atoms *at,
t_param *p, int c_start, bool bB, bool bGenPairs)
{
int i, j, ti, tj, ntype;
return bFound;
}
-static bool default_cmap_params(t_params bondtype[],
+static bool default_cmap_params(gmx::ArrayRef<InteractionTypeParameters> bondtype,
t_atoms *at, gpp_atomtype *atype,
t_param *p, bool bB,
int *cmap_type, int *nparam_def,
ct = 0;
/* Match the current cmap angle against the list of cmap_types */
- for (i = 0; i < bondtype[F_CMAP].nct && !bFound; i += 6)
+ for (i = 0; i < bondtype[F_CMAP].nct() && !bFound; i += 6)
{
if (bB)
{
else
{
if (
- (get_atomtype_batype(at->atom[p->a[0]].type, atype) == bondtype[F_CMAP].cmap_types[i]) &&
- (get_atomtype_batype(at->atom[p->a[1]].type, atype) == bondtype[F_CMAP].cmap_types[i+1]) &&
- (get_atomtype_batype(at->atom[p->a[2]].type, atype) == bondtype[F_CMAP].cmap_types[i+2]) &&
- (get_atomtype_batype(at->atom[p->a[3]].type, atype) == bondtype[F_CMAP].cmap_types[i+3]) &&
- (get_atomtype_batype(at->atom[p->a[4]].type, atype) == bondtype[F_CMAP].cmap_types[i+4]))
+ (get_atomtype_batype(at->atom[p->a[0]].type, atype) == bondtype[F_CMAP].cmapAtomTypes[i]) &&
+ (get_atomtype_batype(at->atom[p->a[1]].type, atype) == bondtype[F_CMAP].cmapAtomTypes[i+1]) &&
+ (get_atomtype_batype(at->atom[p->a[2]].type, atype) == bondtype[F_CMAP].cmapAtomTypes[i+2]) &&
+ (get_atomtype_batype(at->atom[p->a[3]].type, atype) == bondtype[F_CMAP].cmapAtomTypes[i+3]) &&
+ (get_atomtype_batype(at->atom[p->a[4]].type, atype) == bondtype[F_CMAP].cmapAtomTypes[i+4]))
{
/* Found cmap torsion */
bFound = TRUE;
- ct = bondtype[F_CMAP].cmap_types[i+5];
+ ct = bondtype[F_CMAP].cmapAtomTypes[i+5];
nparam_found = 1;
}
}
}
}
-static bool default_params(int ftype, t_params bt[],
- t_atoms *at, gpp_atomtype *atype,
- t_param *p, bool bB,
- t_param **param_def,
- int *nparam_def)
+static bool defaultInteractionTypeParameters(int ftype, gmx::ArrayRef<InteractionTypeParameters> bt,
+ t_atoms *at, gpp_atomtype *atype,
+ t_param *p, bool bB,
+ t_param **param_def,
+ int *nparam_def)
{
int nparam_found;
bool bFound, bSame;
-void push_bond(Directive d, t_params bondtype[], t_params bond[],
+void push_bond(Directive d, gmx::ArrayRef<InteractionTypeParameters> bondtype,
+ gmx::ArrayRef<InteractionTypeParameters> bond,
t_atoms *at, gpp_atomtype *atype, char *line,
bool bBonded, bool bGenPairs, real fudgeQQ,
bool bZero, bool *bWarn_copy_A_B,
if (bBonded)
{
- bFoundA = default_params(ftype, bondtype, at, atype, ¶m, FALSE, ¶m_defA, &nparam_defA);
+ bFoundA = defaultInteractionTypeParameters(ftype, bondtype, at, atype, ¶m, FALSE, ¶m_defA, &nparam_defA);
if (bFoundA)
{
/* Copy the A-state and B-state default parameters. */
param.c[j] = param_defA->c[j];
}
}
- bFoundB = default_params(ftype, bondtype, at, atype, ¶m, TRUE, ¶m_defB, &nparam_defB);
+ bFoundB = defaultInteractionTypeParameters(ftype, bondtype, at, atype, ¶m, TRUE, ¶m_defB, &nparam_defB);
if (bFoundB)
{
/* Copy only the B-state default parameters */
}
}
-void push_cmap(Directive d, t_params bondtype[], t_params bond[],
+void push_cmap(Directive d, gmx::ArrayRef<InteractionTypeParameters> bondtype,
+ gmx::ArrayRef<InteractionTypeParameters> bond,
t_atoms *at, gpp_atomtype *atype, char *line,
warninp *wi)
{
-void push_vsitesn(Directive d, t_params bond[],
+void push_vsitesn(Directive d, gmx::ArrayRef<InteractionTypeParameters> bond,
t_atoms *at, char *line,
warninp *wi)
{
return nr;
}
-static void convert_pairs_to_pairsQ(t_params *plist,
+static void convert_pairs_to_pairsQ(gmx::ArrayRef<InteractionTypeParameters> plist,
real fudgeQQ, t_atoms *atoms)
{
t_param *paramp1, *paramp2, *paramnew;
plist[F_LJ14].param = nullptr;
}
-static void generate_LJCpairsNB(MoleculeInformation *mol, int nb_funct, t_params *nbp, warninp *wi)
+static void generate_LJCpairsNB(MoleculeInformation *mol, int nb_funct, InteractionTypeParameters *nbp, warninp *wi)
{
int n, ntype, i, j, k;
t_atom *atom;
void convert_moltype_couple(MoleculeInformation *mol, int atomtype_decouple, real fudgeQQ,
int couple_lam0, int couple_lam1,
- bool bCoupleIntra, int nb_funct, t_params *nbp,
+ bool bCoupleIntra, int nb_funct, InteractionTypeParameters *nbp,
warninp *wi)
{
convert_pairs_to_pairsQ(mol->plist, fudgeQQ, &mol->atoms);
struct MoleculeInformation;
struct t_nbparam;
struct t_param;
-struct t_params;
+struct InteractionTypeParameters;
struct PreprocessResidue;
struct warninp;
struct ExclusionBlock;
} // namespace gmx
-void generate_nbparams(int comb, int funct, t_params plist[],
+void generate_nbparams(int comb, int funct, InteractionTypeParameters *plist,
gpp_atomtype *atype,
warninp *wi);
t_nbparam ***nbparam, t_nbparam ***pair,
warninp *wi);
-void push_bt(Directive d, t_params bt[], int nral,
+void push_bt(Directive d, gmx::ArrayRef<InteractionTypeParameters> bt, int nral,
gpp_atomtype *at, gpp_bond_atomtype *bat, char *line,
warninp *wi);
-void push_dihedraltype(Directive d, t_params bt[],
+void push_dihedraltype(Directive d, gmx::ArrayRef<InteractionTypeParameters> bt,
gpp_bond_atomtype *bat, char *line,
warninp *wi);
-void push_cmaptype(Directive d, t_params bt[], int nral, gpp_atomtype *at,
+void push_cmaptype(Directive d, gmx::ArrayRef<InteractionTypeParameters> bt, int nral, gpp_atomtype *at,
gpp_bond_atomtype *bat, char *line,
warninp *wi);
int *lastcg,
warninp *wi);
-void push_bond(Directive d, t_params bondtype[], t_params bond[],
+void push_bond(Directive d, gmx::ArrayRef<InteractionTypeParameters> bondtype,
+ gmx::ArrayRef<InteractionTypeParameters> bond,
t_atoms *at, gpp_atomtype *atype, char *line,
bool bBonded, bool bGenPairs, real fudgeQQ,
bool bZero, bool *bWarn_copy_A_B,
warninp *wi);
-void push_cmap(Directive d, t_params bondtype[], t_params bond[],
+void push_cmap(Directive d,
+ gmx::ArrayRef<InteractionTypeParameters> bondtype,
+ gmx::ArrayRef<InteractionTypeParameters> bond,
t_atoms *at, gpp_atomtype *atype, char *line,
warninp *wi);
-void push_vsitesn(Directive d, t_params bond[],
+void push_vsitesn(Directive d, gmx::ArrayRef<InteractionTypeParameters> bond,
t_atoms *at, char *line,
warninp *wi);
void push_excl(char *line, gmx::ArrayRef<gmx::ExclusionBlock> b2, warninp *wi);
-int copy_nbparams(t_nbparam **param, int ftype, t_params *plist, int nr);
+int copy_nbparams(t_nbparam **param, int ftype, InteractionTypeParameters *plist, int nr);
void free_nbparam(t_nbparam **param, int nr);
real fudgeQQ,
int couple_lam0, int couple_lam1,
bool bCoupleIntra,
- int nb_funct, t_params *nbp,
+ int nb_funct, InteractionTypeParameters *nbp,
warninp *wi);
/* Setup mol such that the B-state has no interaction with the rest
* of the system, but full interaction with itself.
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/smalloc.h"
-static void copy_bond (t_params *pr, int to, int from)
+static void copy_bond (InteractionTypeParameters *pr, int to, int from)
/* copies an entry in a bond list to another position.
* does no allocing or freeing of memory
*/
return nh;
}
-void make_shake (t_params plist[], t_atoms *atoms, int nshake)
+void make_shake(gmx::ArrayRef<InteractionTypeParameters> plist, t_atoms *atoms, int nshake)
{
- char ***info = atoms->atomname;
- t_params *pr;
- t_params *bonds;
- t_param p, *bond, *ang;
- real b_ij, b_jk;
- int i, j, ftype, ftype_a;
- bool bFound;
+ char ***info = atoms->atomname;
+ InteractionTypeParameters *pr;
+ InteractionTypeParameters *bonds;
+ t_param p, *bond, *ang;
+ real b_ij, b_jk;
+ int i, j, ftype, ftype_a;
+ bool bFound;
if (nshake != eshNONE)
{
#ifndef GMX_GMXPREPROCESS_TOPSHAKE_H
#define GMX_GMXPREPROCESS_TOPSHAKE_H
+#include "gromacs/utility/arrayref.h"
+
struct t_atoms;
-struct t_params;
+struct InteractionTypeParameters;
-void make_shake (t_params plist[], t_atoms *atoms, int nshake);
+void make_shake (gmx::ArrayRef<InteractionTypeParameters> plist, t_atoms *atoms, int nshake);
#endif
}
}
-void pr_alloc (int extra, t_params *pr)
+void pr_alloc (int extra, InteractionTypeParameters *pr)
{
int i, j;
{
return;
}
- GMX_ASSERT(pr->nr != 0 || pr->param == nullptr, "Invalid t_params object");
+ GMX_ASSERT(pr->nr != 0 || pr->param == nullptr, "Invalid InteractionTypeParameters object");
if (pr->nr+extra > pr->maxnr)
{
pr->maxnr = std::max(static_cast<int>(1.2*pr->maxnr), pr->maxnr + extra);
}
}
-void init_plist(t_params plist[])
+void init_plist(gmx::ArrayRef<InteractionTypeParameters> plist)
{
int i;
plist[i].nr = 0;
plist[i].maxnr = 0;
plist[i].param = nullptr;
-
- /* CMAP */
- plist[i].ncmap = 0;
- plist[i].cmap = nullptr;
- plist[i].grid_spacing = 0;
- plist[i].nc = 0;
- plist[i].nct = 0;
- plist[i].cmap_types = nullptr;
}
}
-void done_plist(t_params *plist)
+void done_plist(gmx::ArrayRef<InteractionTypeParameters> plist)
{
for (int i = 0; i < F_NRE; i++)
{
- t_params *pl = &plist[i];
- sfree(pl->param);
- sfree(pl->cmap);
- sfree(pl->cmap_types);
+ sfree(plist[i].param);
}
}
strncpy(dest->s, src->s, sizeof(dest->s));
}
-void add_param_to_list(t_params *list, t_param *b)
+void add_param_to_list(InteractionTypeParameters *list, t_param *b)
{
int j;
/* PRINTING STRUCTURES */
static void print_bt(FILE *out, Directive d, gpp_atomtype *at,
- int ftype, int fsubtype, t_params plist[],
+ int ftype, int fsubtype, gmx::ArrayRef<const InteractionTypeParameters> plist,
bool bFullDih)
{
/* This dihp is a DIRTY patch because the dih-types do not use
* all four atoms to determine the type.
*/
- const int dihp[2][2] = { { 1, 2 }, { 0, 3 } };
- t_params *bt;
- int i, j, f, nral, nrfp;
- bool bDih = FALSE, bSwapParity;
+ const int dihp[2][2] = { { 1, 2 }, { 0, 3 } };
+ int i, j, f, nral, nrfp;
+ bool bDih = FALSE, bSwapParity;
- bt = &(plist[ftype]);
+ const InteractionTypeParameters *bt = &(plist[ftype]);
if (!bt->nr)
{
}
void print_bondeds(FILE *out, int natoms, Directive d,
- int ftype, int fsubtype, t_params plist[])
+ int ftype, int fsubtype, gmx::ArrayRef<const InteractionTypeParameters> plist)
{
t_symtab stab;
gpp_atomtype *atype;
#include <cstdio>
+#include "gromacs/utility/arrayref.h"
+
enum class Directive : int;
struct gpp_atomtype;
struct t_atoms;
struct t_excls;
struct MoleculeInformation;
struct t_param;
-struct t_params;
+struct InteractionTypeParameters;
/* UTILITIES */
int name2index(char *str, char ***typenames, int ntypes);
-void pr_alloc (int extra, t_params *pr);
+void pr_alloc (int extra, InteractionTypeParameters *pr);
void set_p_string(t_param *p, const char *s);
void cp_param(t_param *dest, t_param *src);
-void add_param_to_list(t_params *list, t_param *b);
+void add_param_to_list(InteractionTypeParameters *list, t_param *b);
/* INITIATE */
-void init_plist(t_params plist[]);
-void done_plist(t_params *plist);
+void init_plist(gmx::ArrayRef<InteractionTypeParameters> plist);
+void done_plist(gmx::ArrayRef<InteractionTypeParameters> plist);
/* PRINTING */
bool bRTPresname);
void print_bondeds(FILE *out, int natoms, Directive d,
- int ftype, int fsubtype, t_params plist[]);
+ int ftype, int fsubtype, gmx::ArrayRef<const InteractionTypeParameters> plist);
void print_excl(FILE *out, int natoms, t_excls excls[]);
}
}
-static at2vsitebond_t *make_at2vsitebond(int natoms, t_params plist[])
+static at2vsitebond_t *make_at2vsitebond(int natoms, gmx::ArrayRef<InteractionTypeParameters> plist)
{
bool *bVSI;
int ftype, i, j, nrcheck, nr;
sfree(at2vb);
}
-static at2vsitecon_t *make_at2vsitecon(int natoms, t_params plist[])
+static at2vsitecon_t *make_at2vsitecon(int natoms, gmx::ArrayRef<InteractionTypeParameters> plist)
{
bool *bVSI;
int ftype, i, j, ai, aj, nr;
int set_vsites(bool bVerbose, t_atoms *atoms, gpp_atomtype *atype,
- t_params plist[])
+ gmx::ArrayRef<InteractionTypeParameters> plist)
{
int i, j, ftype;
int nvsite, nrbond, nrang, nridih, nrset;
int ftype, parnr;
} t_pindex;
-static void check_vsite_constraints(t_params *plist,
+static void check_vsite_constraints(gmx::ArrayRef<InteractionTypeParameters> plist,
int cftype, const int vsite_type[])
{
- int i, k, n;
- int atom;
- t_params *ps;
+ int i, k, n;
+ int atom;
+ InteractionTypeParameters *ps;
n = 0;
ps = &(plist[cftype]);
}
}
-static void clean_vsite_bonds(t_params *plist, t_pindex pindex[],
+static void clean_vsite_bonds(gmx::ArrayRef<InteractionTypeParameters> plist, t_pindex pindex[],
int cftype, const int vsite_type[])
{
- int ftype, i, j, k, m, n, nvsite, nOut, kept_i;
- int nconverted, nremoved;
- int atom, oatom, at1, at2;
- bool bKeep, bRemove, bUsed, bPresent, bThisFD, bThisOUT, bAllFD, bFirstTwo;
- t_params *ps;
+ int ftype, i, j, k, m, n, nvsite, nOut, kept_i;
+ int nconverted, nremoved;
+ int atom, oatom, at1, at2;
+ bool bKeep, bRemove, bUsed, bPresent, bThisFD, bThisOUT, bAllFD, bFirstTwo;
+ InteractionTypeParameters *ps;
if (cftype == F_CONNBONDS)
{
ps->nr = kept_i;
}
-static void clean_vsite_angles(t_params *plist, t_pindex pindex[],
+static void clean_vsite_angles(gmx::ArrayRef<InteractionTypeParameters> plist, t_pindex pindex[],
int cftype, const int vsite_type[],
at2vsitecon_t *at2vc)
{
- int i, j, k, m, n, nvsite, kept_i;
- int atom, at1, at2;
- bool bKeep, bUsed, bPresent, bAll3FAD, bFirstTwo;
- t_params *ps;
+ int i, j, k, m, n, nvsite, kept_i;
+ int atom, at1, at2;
+ bool bKeep, bUsed, bPresent, bAll3FAD, bFirstTwo;
+ InteractionTypeParameters *ps;
ps = &(plist[cftype]);
kept_i = 0;
ps->nr = kept_i;
}
-static void clean_vsite_dihs(t_params *plist, t_pindex pindex[],
+static void clean_vsite_dihs(gmx::ArrayRef<InteractionTypeParameters> plist, t_pindex pindex[],
int cftype, const int vsite_type[])
{
- int i, kept_i;
- t_params *ps;
+ int i, kept_i;
+ InteractionTypeParameters *ps;
ps = &(plist[cftype]);
ps->nr = kept_i;
}
-void clean_vsite_bondeds(t_params *plist, int natoms, bool bRmVSiteBds)
+void clean_vsite_bondeds(gmx::ArrayRef<InteractionTypeParameters> plist, int natoms, bool bRmVSiteBds)
{
int i, k, nvsite, ftype, vsite, parnr;
int *vsite_type;
#ifndef GMX_GMXPREPROCESS_VSITE_PARM_H
#define GMX_GMXPREPROCESS_VSITE_PARM_H
+#include "gromacs/utility/arrayref.h"
+
struct gpp_atomtype;
struct gmx_moltype_t;
struct t_atoms;
-struct t_params;
+struct InteractionTypeParameters;
int set_vsites(bool bVerbose, t_atoms *atoms, gpp_atomtype *atype,
- t_params plist[]);
+ gmx::ArrayRef<InteractionTypeParameters> plist);
/* set parameters for virtual sites, return number of virtual sites */
void set_vsites_ptype(bool bVerbose, gmx_moltype_t *molt);
*
* Throw away all obsolete bonds, angles and dihedrals.
* Throw away all constraints. */
-void clean_vsite_bondeds(t_params *ps, int natoms, bool bRmVSiteBds);
+void clean_vsite_bondeds(gmx::ArrayRef<InteractionTypeParameters> ps, int natoms, bool bRmVSiteBds);
#endif
}
static void mk_bonds(int nnm, t_nm2type nmt[],
- t_atoms *atoms, const rvec x[], t_params *bond, int nbond[],
+ t_atoms *atoms, const rvec x[], InteractionTypeParameters *bond, int nbond[],
bool bPBC, matrix box)
{
t_param b;
return cgnr;
}
-static gpp_atomtype *set_atom_type(t_symtab *tab, t_atoms *atoms, t_params *bonds,
+static gpp_atomtype *set_atom_type(t_symtab *tab, t_atoms *atoms, InteractionTypeParameters *bonds,
int *nbonds, int nnm, t_nm2type nm2t[])
{
gpp_atomtype *atype;
return atype;
}
-static void lo_set_force_const(t_params *plist, real c[], int nrfp, bool bRound,
+static void lo_set_force_const(InteractionTypeParameters *plist, real c[], int nrfp, bool bRound,
bool bDih, bool bParam)
{
- int i, j;
double cc;
char buf[32];
- for (i = 0; (i < plist->nr); i++)
+ for (int i = 0; (i < plist->nr); i++)
{
if (!bParam)
{
- for (j = 0; j < nrfp; j++)
+ for (int j = 0; j < nrfp; j++)
{
c[j] = NOTSET;
}
}
}
GMX_ASSERT(nrfp <= MAXFORCEPARAM/2, "Only 6 parameters may be used for an interaction");
- for (j = 0; (j < nrfp); j++)
+ for (int j = 0; (j < nrfp); j++)
{
plist->param[i].c[j] = c[j];
plist->param[i].c[nrfp+j] = c[j];
}
}
-static void set_force_const(t_params plist[], real kb, real kt, real kp, bool bRound,
+static void set_force_const(gmx::ArrayRef<InteractionTypeParameters> plist, real kb, real kt, real kp, bool bRound,
bool bParam)
{
real c[MAXFORCEPARAM];
lo_set_force_const(&plist[F_PDIHS], c, 3, bRound, TRUE, bParam);
}
-static void calc_angles_dihs(t_params *ang, t_params *dih, const rvec x[], bool bPBC,
+static void calc_angles_dihs(InteractionTypeParameters *ang, InteractionTypeParameters *dih, const rvec x[], bool bPBC,
matrix box)
{
- int i, ai, aj, ak, al, t1, t2, t3;
+ int t1, t2, t3;
rvec r_ij, r_kj, r_kl, m, n;
- real th, costh, ph;
+ real costh;
t_pbc pbc;
if (bPBC)
{
set_pbc(&pbc, epbcXYZ, box);
}
- for (i = 0; (i < ang->nr); i++)
+ for (int i = 0; (i < ang->nr); i++)
{
- ai = ang->param[i].ai();
- aj = ang->param[i].aj();
- ak = ang->param[i].ak();
- th = RAD2DEG*bond_angle(x[ai], x[aj], x[ak], bPBC ? &pbc : nullptr,
- r_ij, r_kj, &costh, &t1, &t2);
+ int ai = ang->param[i].ai();
+ int aj = ang->param[i].aj();
+ int ak = ang->param[i].ak();
+ real th = RAD2DEG*bond_angle(x[ai], x[aj], x[ak], bPBC ? &pbc : nullptr,
+ r_ij, r_kj, &costh, &t1, &t2);
ang->param[i].c0() = th;
}
- for (i = 0; (i < dih->nr); i++)
+ for (int i = 0; (i < dih->nr); i++)
{
- ai = dih->param[i].ai();
- aj = dih->param[i].aj();
- ak = dih->param[i].ak();
- al = dih->param[i].al();
- ph = RAD2DEG*dih_angle(x[ai], x[aj], x[ak], x[al], bPBC ? &pbc : nullptr,
- r_ij, r_kj, r_kl, m, n, &t1, &t2, &t3);
+ int ai = dih->param[i].ai();
+ int aj = dih->param[i].aj();
+ int ak = dih->param[i].ak();
+ int al = dih->param[i].al();
+ real ph = RAD2DEG*dih_angle(x[ai], x[aj], x[ak], x[al], bPBC ? &pbc : nullptr,
+ r_ij, r_kj, r_kl, m, n, &t1, &t2, &t3);
dih->param[i].c0() = ph;
}
}
}
}
-static void print_pl(FILE *fp, t_params plist[], int ftp, const char *name,
+static void print_pl(FILE *fp, gmx::ArrayRef<const InteractionTypeParameters> plist, int ftp, const char *name,
char ***atomname)
{
- int i, j, nral, nrfp;
-
if (plist[ftp].nr > 0)
{
fprintf(fp, "\n");
fprintf(fp, "[ %s ]\n", name);
- nral = interaction_function[ftp].nratoms;
- nrfp = interaction_function[ftp].nrfpA;
- for (i = 0; (i < plist[ftp].nr); i++)
+ int nral = interaction_function[ftp].nratoms;
+ int nrfp = interaction_function[ftp].nrfpA;
+ for (int i = 0; (i < plist[ftp].nr); i++)
{
- for (j = 0; (j < nral); j++)
+ for (int j = 0; (j < nral); j++)
{
fprintf(fp, " %5s", *atomname[plist[ftp].param[i].a[j]]);
}
- for (j = 0; (j < nrfp); j++)
+ for (int j = 0; (j < nrfp); j++)
{
if (plist[ftp].param[i].c[j] != NOTSET)
{
}
static void print_rtp(const char *filenm, const char *title, t_atoms *atoms,
- t_params plist[], gpp_atomtype *atype, int cgnr[])
+ gmx::ArrayRef<const InteractionTypeParameters> plist, gpp_atomtype *atype, int cgnr[])
{
FILE *fp;
int i, tp;
int gmx_x2top(int argc, char *argv[])
{
- const char *desc[] = {
+ const char *desc[] = {
"[THISMODULE] generates a primitive topology from a coordinate file.",
"The program assumes all hydrogens are present when defining",
"the hybridization from the atom name and the number of bonds.",
"one of the short names above on the command line instead. In that",
"case [THISMODULE] just looks for the corresponding file.[PAR]",
};
- const char *bugs[] = {
+ const char *bugs[] = {
"The atom type selection is primitive. Virtually no chemical knowledge is used",
"Periodic boundary conditions screw up the bonding",
"No improper dihedrals are generated",
"The atoms to atomtype translation table is incomplete ([TT]atomname2type.n2t[tt] file in the data directory). Please extend it and send the results back to the GROMACS crew."
};
- FILE *fp;
- t_params plist[F_NRE];
- t_excls *excls;
- gpp_atomtype *atype;
- t_nextnb nnb;
- t_nm2type *nm2t;
- t_mols mymol;
- int nnm;
- char forcefield[32], ffdir[STRLEN];
- rvec *x; /* coordinates? */
- int *nbonds, *cgnr;
- int bts[] = { 1, 1, 1, 2 };
- matrix box; /* box length matrix */
- int natoms; /* number of atoms in one molecule */
- int epbc;
- bool bRTP, bTOP, bOPLS;
- t_symtab symtab;
- real qtot, mtot;
- char n2t[STRLEN];
- gmx_output_env_t *oenv;
-
- t_filenm fnm[] = {
+ FILE *fp;
+ std::array<InteractionTypeParameters, F_NRE> plist;
+ t_excls *excls;
+ gpp_atomtype *atype;
+ t_nextnb nnb;
+ t_nm2type *nm2t;
+ t_mols mymol;
+ int nnm;
+ char forcefield[32], ffdir[STRLEN];
+ rvec *x; /* coordinates? */
+ int *nbonds, *cgnr;
+ int bts[] = { 1, 1, 1, 2 };
+ matrix box; /* box length matrix */
+ int natoms; /* number of atoms in one molecule */
+ int epbc;
+ bool bRTP, bTOP, bOPLS;
+ t_symtab symtab;
+ real qtot, mtot;
+ char n2t[STRLEN];
+ gmx_output_env_t *oenv;
+
+ t_filenm fnm[] = {
{ efSTX, "-f", "conf", ffREAD },
{ efTOP, "-o", "out", ffOPTWR },
{ efRTP, "-r", "out", ffOPTWR }
};
#define NFILE asize(fnm)
- real kb = 4e5, kt = 400, kp = 5;
- PreprocessResidue rtp_header_settings;
- bool bRemoveDihedralIfWithImproper = FALSE;
- bool bGenerateHH14Interactions = TRUE;
- bool bKeepAllGeneratedDihedrals = FALSE;
- int nrexcl = 3;
- bool bParam = TRUE, bRound = TRUE;
- bool bPairs = TRUE, bPBC = TRUE;
- bool bUsePDBcharge = FALSE, bVerbose = FALSE;
- const char *molnm = "ICE";
- const char *ff = "oplsaa";
- t_pargs pa[] = {
+ real kb = 4e5, kt = 400, kp = 5;
+ PreprocessResidue rtp_header_settings;
+ bool bRemoveDihedralIfWithImproper = FALSE;
+ bool bGenerateHH14Interactions = TRUE;
+ bool bKeepAllGeneratedDihedrals = FALSE;
+ int nrexcl = 3;
+ bool bParam = TRUE, bRound = TRUE;
+ bool bPairs = TRUE, bPBC = TRUE;
+ bool bUsePDBcharge = FALSE, bVerbose = FALSE;
+ const char *molnm = "ICE";
+ const char *ff = "oplsaa";
+ t_pargs pa[] = {
{ "-ff", FALSE, etSTR, {&ff},
"Force field for your simulation. Type \"select\" for interactive selection." },
{ "-v", FALSE, etBOOL, {&bVerbose},
mymol.name = gmx_strdup(molnm);
mymol.nr = 1;
- /* Init parameter lists */
- init_plist(plist);
-
/* Read coordinates */
t_topology *top;
snew(top, 1);