for (int k = 0; (k < etiNR); k++)
{
- /* Now fill data for tables that should not be read (perhaps
- overwriting data that was read but should not be used) */
- if (!ETAB_USER(tabsel[k]))
+ /* Now fill data for tables that have not been read
+ * or add the Ewald long-range correction for Ewald user tables.
+ */
+ if (tabsel[k] != etabUSER)
{
real scale = table->scale;
- if (fr->bBHAM && (fr->bham_b_max != 0) && tabsel[k] == etabEXPMIN)
+ if (ic->useBuckingham &&
+ (ic->buckinghamBMax != 0) &&
+ tabsel[k] == etabEXPMIN)
{
- scale /= fr->bham_b_max;
+ scale /= ic->buckinghamBMax;
}
init_table(table->n, nx0, scale, &(td[k]), !useUserTable);
}
}
}
- for (i = 0; (i < a1->nr); i++)
+
+static void cmp_atom(FILE *fp, int index, const t_atom *a1, const t_atom *a2, real ftol, real abstol)
+{
+ if (a2)
+ {
+ cmp_us(fp, "atom.type", index, a1->type, a2->type);
+ cmp_us(fp, "atom.ptype", index, a1->ptype, a2->ptype);
+ cmp_int(fp, "atom.resind", index, a1->resind, a2->resind);
+ cmp_int(fp, "atom.atomnumber", index, a1->atomnumber, a2->atomnumber);
+ cmp_real(fp, "atom.m", index, a1->m, a2->m, ftol, abstol);
+ cmp_real(fp, "atom.q", index, a1->q, a2->q, ftol, abstol);
+ cmp_us(fp, "atom.typeB", index, a1->typeB, a2->typeB);
+ cmp_real(fp, "atom.mB", index, a1->mB, a2->mB, ftol, abstol);
+ cmp_real(fp, "atom.qB", index, a1->qB, a2->qB, ftol, abstol);
+ }
+ else
+ {
+ cmp_us(fp, "atom.type", index, a1->type, a1->typeB);
+ cmp_real(fp, "atom.m", index, a1->m, a1->mB, ftol, abstol);
+ cmp_real(fp, "atom.q", index, a1->q, a1->qB, ftol, abstol);
+ }
+}
+
+void cmp_atoms(FILE *fp, const t_atoms *a1, const t_atoms *a2, real ftol, real abstol)
+{
+ int i;
+
+ fprintf(fp, "comparing atoms\n");
+
+ if (a2)
+ {
+ cmp_int(fp, "atoms->nr", -1, a1->nr, a2->nr);
++ for (i = 0; i < std::min(a1->nr, a2->nr); i++)
+ {
+ cmp_atom(fp, i, &(a1->atom[i]), &(a2->atom[i]), ftol, abstol);
+ }
+ }
+ else
+ {
+ for (i = 0; (i < a1->nr); i++)
+ {
+ cmp_atom(fp, i, &(a1->atom[i]), nullptr, ftol, abstol);
+ }
+ }
+}
+
+void atomsSetMassesBasedOnNames(t_atoms *atoms, gmx_bool printMissingMasses)
+{
+ if (atoms->haveMass)
+ {
+ /* We could decide to anyhow assign then or generate a fatal error,
+ * but it's probably most useful to keep the masses we have.
+ */
+ return;
+ }
+
+ int maxWarn = (printMissingMasses ? 10 : 0);
+ int numWarn = 0;
+
+ gmx_atomprop_t aps = gmx_atomprop_init();
+
+ gmx_bool haveMass = TRUE;
+ for (int i = 0; i < atoms->nr; i++)
+ {
+ if (!gmx_atomprop_query(aps, epropMass,
+ *atoms->resinfo[atoms->atom[i].resind].name,
+ *atoms->atomname[i],
+ &atoms->atom[i].m))
+ {
+ haveMass = FALSE;
+
+ if (numWarn < maxWarn)
+ {
+ fprintf(stderr, "Can not find mass in database for atom %s in residue %d %s\n",
+ *atoms->atomname[i],
+ atoms->resinfo[atoms->atom[i].resind].nr,
+ *atoms->resinfo[atoms->atom[i].resind].name);
+ numWarn++;
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+ atoms->haveMass = haveMass;
+
+ gmx_atomprop_destroy(aps);
+}