#include "gromacs/utility/futil.h"
#include "gromacs/utility/smalloc.h"
-typedef struct {
+typedef struct
+{
char *ai, *aj;
real e_diss;
} t_2morse;
-static t_2morse *read_dissociation_energies(int *n2morse)
+static t_2morse* read_dissociation_energies(int* n2morse)
{
char ai[32], aj[32];
double e_diss;
- const char *fn = "edissoc.dat";
- t_2morse *t2m = nullptr;
+ const char* fn = "edissoc.dat";
+ t_2morse* t2m = nullptr;
int maxn2m = 0, n2m = 0;
int nread;
n2m++;
}
/* If we did not read three items, quit reading */
- }
- while (nread == 3);
+ } while (nread == 3);
/* Set the return values */
*n2morse = n2m;
return t2m;
}
-static int nequal(const char *a1, const char *a2)
+static int nequal(const char* a1, const char* a2)
{
int i;
return i;
}
-static real search_e_diss(int n2m, t_2morse t2m[], const char *ai, const char *aj)
+static real search_e_diss(int n2m, t_2morse t2m[], const char* ai, const char* aj)
{
int i;
int ibest = -1;
for (i = 0; (i < n2m); i++)
{
/* Check for a perfect match */
- if (((gmx_strcasecmp(t2m[i].ai, ai) == 0) && (gmx_strcasecmp(t2m[i].aj, aj) == 0)) ||
- ((gmx_strcasecmp(t2m[i].aj, ai) == 0) && (gmx_strcasecmp(t2m[i].ai, aj) == 0)))
+ if (((gmx_strcasecmp(t2m[i].ai, ai) == 0) && (gmx_strcasecmp(t2m[i].aj, aj) == 0))
+ || ((gmx_strcasecmp(t2m[i].aj, ai) == 0) && (gmx_strcasecmp(t2m[i].ai, aj) == 0)))
{
ibest = i;
break;
*/
nii = nequal(t2m[i].ai, ai);
njj = nequal(t2m[i].aj, aj);
- if (((nii > nbstii) && (njj >= nbstjj)) ||
- ((nii >= nbstii) && (njj > nbstjj)))
+ if (((nii > nbstii) && (njj >= nbstjj)) || ((nii >= nbstii) && (njj > nbstjj)))
{
if ((nii > 0) && (njj > 0))
{
/* Swap ai and aj (at least in counting the number of equal chars) */
nii = nequal(t2m[i].ai, aj);
njj = nequal(t2m[i].aj, ai);
- if (((nii > nbstii) && (njj >= nbstjj)) ||
- ((nii >= nbstii) && (njj > nbstjj)))
+ if (((nii > nbstii) && (njj >= nbstjj)) || ((nii >= nbstii) && (njj > nbstjj)))
{
if ((nii > 0) && (njj > 0))
{
}
}
-void convert_harmonics(gmx::ArrayRef<MoleculeInformation> mols, PreprocessingAtomTypes *atype)
+void convert_harmonics(gmx::ArrayRef<MoleculeInformation> mols, PreprocessingAtomTypes* atype)
{
int n2m;
- t_2morse *t2m;
+ t_2morse* t2m;
/* First get the data */
t2m = read_dissociation_energies(&n2m);
/* For all the molecule types */
int i = 0;
- for (auto &mol : mols)
+ for (auto& mol : mols)
{
/* Check how many morse and harmonic BONDSs there are, increase size of
* morse with the number of harmonics
{
if ((interaction_function[bb].flags & IF_BTYPE) && (bb != F_MORSE))
{
- int nrharm = mol.interactions[bb].size();
+ int nrharm = mol.interactions[bb].size();
/* Now loop over the harmonics, trying to convert them */
for (auto harmonic = mol.interactions[bb].interactionTypes.begin();
- harmonic != mol.interactions[bb].interactionTypes.end(); )
+ harmonic != mol.interactions[bb].interactionTypes.end();)
{
int ni = harmonic->ai();
int nj = harmonic->aj();
- real edis =
- search_e_diss(n2m, t2m,
- atype->atomNameFromAtomType(mol.atoms.atom[ni].type),
- atype->atomNameFromAtomType(mol.atoms.atom[nj].type));
+ real edis = search_e_diss(n2m, t2m,
+ atype->atomNameFromAtomType(mol.atoms.atom[ni].type),
+ atype->atomNameFromAtomType(mol.atoms.atom[nj].type));
if (edis != 0)
{
- real b0 = harmonic->c0();
- real kb = harmonic->c1();
- real beta = std::sqrt(kb/(2*edis));
- std::vector<int> atoms = {ni, nj};
- std::vector<real> forceParam = {b0, edis, beta};
+ real b0 = harmonic->c0();
+ real kb = harmonic->c1();
+ real beta = std::sqrt(kb / (2 * edis));
+ std::vector<int> atoms = { ni, nj };
+ std::vector<real> forceParam = { b0, edis, beta };
mol.interactions[F_MORSE].interactionTypes.emplace_back(
InteractionOfType(atoms, forceParam));
harmonic = mol.interactions[bb].interactionTypes.erase(harmonic);
int newHarmonics = mol.interactions[bb].size();
fprintf(stderr, "Converted %d out of %d %s to morse bonds for mol %d\n",
- nrharm-newHarmonics, nrharm, interaction_function[bb].name, i);
+ nrharm - newHarmonics, nrharm, interaction_function[bb].name, i);
}
}
i++;