static const char* SwS = { "SWAP:" }; /**< For output that comes from the swap module */
static const char* SwSEmpty = { " " }; /**< Placeholder for multi-line output */
-static const char* CompStr[eCompNR] = { "A", "B" }; /**< Compartment name */
-static const char* SwapStr[eSwapTypesNR + 1] = { "", "X-", "Y-", "Z-",
- nullptr }; /**< Name for the swap types. */
+static const char* CompStr[eCompNR] = { "A", "B" }; /**< Compartment name */
+static const char* SwapStr[eSwapTypesNR + 1] = { "", "X-", "Y-", "Z-", nullptr }; /**< Name for the swap types. */
static const char* DimStr[DIM + 1] = { "X", "Y", "Z", nullptr }; /**< Name for the swap dimension. */
/** Keep track of through which channel the ions have passed */
eDomainB,
eDomainNr
};
-static const char* DomainString[eDomainNr] = { "not_assigned", "Domain_A",
- "Domain_B" }; /**< Name for the domains */
+static const char* DomainString[eDomainNr] = { "not_assigned", "Domain_A", "Domain_B" }; /**< Name for the domains */
namespace gmx
{
}
// Output center of split groups
- fprintf(s->fpout, "%10g%10g", s->group[eGrpSplit0].center[s->swapdim],
+ fprintf(s->fpout,
+ "%10g%10g",
+ s->group[eGrpSplit0].center[s->swapdim],
s->group[eGrpSplit1].center[s->swapdim]);
// Output ion flux for each channel and ion type
sd = s->swapdim;
/* Check whether ion is inside any of the channels */
- in_cyl0 = is_in_channel(atomPosition, s->group[eGrpSplit0].center, sc->cyl0u, sc->cyl0l,
- cyl0_r2, s->pbc, sd);
- in_cyl1 = is_in_channel(atomPosition, s->group[eGrpSplit1].center, sc->cyl1u, sc->cyl1l,
- cyl1_r2, s->pbc, sd);
+ in_cyl0 = is_in_channel(
+ atomPosition, s->group[eGrpSplit0].center, sc->cyl0u, sc->cyl0l, cyl0_r2, s->pbc, sd);
+ in_cyl1 = is_in_channel(
+ atomPosition, s->group[eGrpSplit1].center, sc->cyl1u, sc->cyl1l, cyl1_r2, s->pbc, sd);
if (in_cyl0 && in_cyl1)
{
case eChHistPassedNone:
++s->fluxleak;
- fprintf(stderr, " %s Warning! Step %s, ion %d moved from %s to %s\n", SwS,
- gmx_step_str(step, buf), iAtom, DomainString[*comp_from],
+ fprintf(stderr,
+ " %s Warning! Step %s, ion %d moved from %s to %s\n",
+ SwS,
+ gmx_step_str(step, buf),
+ iAtom,
+ DomainString[*comp_from],
DomainString[*comp_now]);
if (bRerun)
{
fprintf(s->fpout,
" # Warning: step %s, ion %d moved from %s to %s (probably through the "
"membrane)\n",
- gmx_step_str(step, buf), iAtom, DomainString[*comp_from],
+ gmx_step_str(step, buf),
+ iAtom,
+ DomainString[*comp_from],
DomainString[*comp_now]);
}
break;
{
g->fluxfromAtoB[chan_nr]--;
}
- fprintf(fpout, "# Atom nr. %d finished passing %s.\n", iAtom,
- ChannelString[*channel_label]);
+ fprintf(fpout, "# Atom nr. %d finished passing %s.\n", iAtom, ChannelString[*channel_label]);
break;
default:
gmx_fatal(FARGS, "%s Unknown channel history entry for ion type '%s'\n", SwS, g->molname);
int sd = s->swapdim;
/* Is this first atom of the molecule in the compartment that we look at? */
- if (compartment_contains_atom(left, right, g->xc[iAtom][sd], box[sd][sd],
- sc->bulkOffset[comp], &dist))
+ if (compartment_contains_atom(
+ left, right, g->xc[iAtom][sd], box[sd][sd], sc->bulkOffset[comp], &dist))
{
/* Add the first atom of this molecule to the list of molecules in this compartment */
add_to_list(iAtom, &g->comp[comp], dist);
if (MASTER(cr) && (g->comp_now != nullptr) && !bIsSolvent)
{
int globalAtomNr = g->atomset.globalIndex()[iAtom] + 1; /* PDB index starts at 1 ... */
- detect_flux_per_channel(g, globalAtomNr, comp, g->xc[iAtom], &g->comp_now[iMol],
- &g->comp_from[iMol], &g->channel_label[iMol], sc, s,
- cyl0_r2, cyl1_r2, step, bRerun, fpout);
+ detect_flux_per_channel(g,
+ globalAtomNr,
+ comp,
+ g->xc[iAtom],
+ &g->comp_now[iMol],
+ &g->comp_from[iMol],
+ &g->channel_label[iMol],
+ sc,
+ s,
+ cyl0_r2,
+ cyl1_r2,
+ step,
+ bRerun,
+ fpout);
}
}
else
"split\n"
"%s cylinder is way too large, or one compartment has collapsed (step "
"%" PRId64 ")\n",
- SwS, g->nCylBoth, SwS, step);
+ SwS,
+ g->nCylBoth,
+ SwS,
+ step);
fprintf(s->fpout, "Warning: %d atoms were assigned to both channels!\n", g->nCylBoth);
if (bIsSolvent && nullptr != fpout)
{
- fprintf(fpout, "# Solv. molecules in comp.%s: %d comp.%s: %d\n", CompStr[eCompA],
- g->comp[eCompA].nMol, CompStr[eCompB], g->comp[eCompB].nMol);
+ fprintf(fpout,
+ "# Solv. molecules in comp.%s: %d comp.%s: %d\n",
+ CompStr[eCompA],
+ g->comp[eCompA].nMol,
+ CompStr[eCompB],
+ g->comp[eCompB].nMol);
}
/* Consistency checks */
fprintf(stderr,
"%s Warning: Inconsistency while assigning '%s' molecules to compartments. !inA: "
"%d, !inB: %d, total molecules %d\n",
- SwS, g->molname, nMolNotInComp[eCompA], nMolNotInComp[eCompB], numMolecules);
+ SwS,
+ g->molname,
+ nMolNotInComp[eCompA],
+ nMolNotInComp[eCompB],
+ numMolecules);
}
int sum = g->comp[eCompA].nMol + g->comp[eCompB].nMol;
fprintf(stderr,
"%s Warning: %d molecules are in group '%s', but altogether %d have been assigned "
"to the compartments.\n",
- SwS, numMolecules, g->molname, sum);
+ SwS,
+ numMolecules,
+ g->molname,
+ sum);
}
}
"Mismatch of the number of %s ions summed over both compartments.\n"
"You requested a total of %d ions (%d in A and %d in B),\n"
"but there are a total of %d ions of this type in the system.\n",
- g->molname, req, g->comp[eCompA].nMolReq, g->comp[eCompB].nMolReq, tot);
+ g->molname,
+ req,
+ g->comp[eCompA].nMolReq,
+ g->comp[eCompB].nMolReq,
+ tot);
}
/* Initialize time-averaging:
if (bVerbose)
{
- fprintf(stderr, "%s ... Influx netto: %d Requested: %d Past values: ", SwS,
- g->comp[ic].inflow_net, g->comp[ic].nMolReq);
+ fprintf(stderr,
+ "%s ... Influx netto: %d Requested: %d Past values: ",
+ SwS,
+ g->comp[ic].inflow_net,
+ g->comp[ic].nMolReq);
}
for (int j = 0; j < sc->nAverage; j++)
{
gmx_bcast(sizeof(g->comp[ic].nMolReq), &(g->comp[ic].nMolReq), cr->mpi_comm_mygroup);
gmx_bcast(sizeof(g->comp[ic].nMol), &(g->comp[ic].nMol), cr->mpi_comm_mygroup);
- gmx_bcast(swap->nAverage * sizeof(g->comp[ic].nMolPast[0]), g->comp[ic].nMolPast,
- cr->mpi_comm_mygroup);
+ gmx_bcast(swap->nAverage * sizeof(g->comp[ic].nMolPast[0]), g->comp[ic].nMolPast, cr->mpi_comm_mygroup);
}
}
}
"groups, or the solvent.\n"
"%s Check the .mdp file settings regarding the swap index groups or the index "
"groups themselves.\n",
- SwS, nMultiple, (1 == nMultiple) ? " is" : "s are", SwSEmpty, SwSEmpty);
+ SwS,
+ nMultiple,
+ (1 == nMultiple) ? " is" : "s are",
+ SwSEmpty,
+ SwSEmpty);
}
}
if (bVerbose)
{
- fprintf(stderr, "%s Checking whether all %s molecules consist of %d atom%s\n", SwS,
- g->molname, apm, apm > 1 ? "s" : "");
+ fprintf(stderr,
+ "%s Checking whether all %s molecules consist of %d atom%s\n",
+ SwS,
+ g->molname,
+ apm,
+ apm > 1 ? "s" : "");
}
/* Check whether this is also true for all other solvent atoms */
snprintf(buf, STRLEN, "%s %s ions (charge %s%g)", CompStr[ic], g->molname, q > 0 ? "+" : "", q);
legend[count++] = gmx_strdup(buf);
- snprintf(buf, STRLEN, "%s av. mismatch to %d %s ions", CompStr[ic],
- s->group[ig].comp[ic].nMolReq, g->molname);
+ snprintf(buf,
+ STRLEN,
+ "%s av. mismatch to %d %s ions",
+ CompStr[ic],
+ s->group[ig].comp[ic].nMolReq,
+ g->molname);
legend[count++] = gmx_strdup(buf);
snprintf(buf, STRLEN, "%s net %s ion influx", CompStr[ic], g->molname);
}
// Center of split groups
- snprintf(buf, STRLEN, "%scenter of %s of split group 0", SwapStr[ir->eSwapCoords],
+ snprintf(buf,
+ STRLEN,
+ "%scenter of %s of split group 0",
+ SwapStr[ir->eSwapCoords],
(nullptr != s->group[eGrpSplit0].m) ? "mass" : "geometry");
legend[count++] = gmx_strdup(buf);
- snprintf(buf, STRLEN, "%scenter of %s of split group 1", SwapStr[ir->eSwapCoords],
+ snprintf(buf,
+ STRLEN,
+ "%scenter of %s of split group 1",
+ SwapStr[ir->eSwapCoords],
(nullptr != s->group[eGrpSplit1].m) ? "mass" : "geometry");
legend[count++] = gmx_strdup(buf);
for (int ic = 0; ic < eChanNR; ic++)
{
- fprintf(stderr, "%s Channel %d flux history for ion type %s (charge %g): ", SwS, ic,
- g->molname, g->q);
+ fprintf(stderr, "%s Channel %d flux history for ion type %s (charge %g): ", SwS, ic, g->molname, g->q);
if (isRestart)
{
g->fluxfromAtoB[ic] = gs->fluxfromAtoB[ic];
"whole.\n"
"%s In case of multimeric channels, please check whether they have the correct PBC "
"representation.\n",
- SwS, SwSEmpty);
+ SwS,
+ SwSEmpty);
- write_sto_conf_mtop("CompELAssumedWholeConfiguration.pdb", *mtop->name, mtop, x, nullptr,
- pbcType, box);
+ write_sto_conf_mtop(
+ "CompELAssumedWholeConfiguration.pdb", *mtop->name, mtop, x, nullptr, pbcType, box);
}
}
{
if (g->nat != (g->nmolReq[eCompA] + g->nmolReq[eCompB]))
{
- gmx_fatal_collective(FARGS, cr->mpi_comm_mysim, MASTER(cr),
+ gmx_fatal_collective(FARGS,
+ cr->mpi_comm_mysim,
+ MASTER(cr),
"%s Inconsistency while importing swap-related data from an old "
"input file version.\n"
"%s The requested ion counts in compartments A (%d) and B (%d)\n"
"%s do not add up to the number of ions (%d) of this type for the "
"group '%s'.\n",
- SwS, SwSEmpty, g->nmolReq[eCompA], g->nmolReq[eCompB], SwSEmpty,
- g->nat, g->molname);
+ SwS,
+ SwSEmpty,
+ g->nmolReq[eCompA],
+ g->nmolReq[eCompB],
+ SwSEmpty,
+ g->nat,
+ g->molname);
}
}
if (bVerbose)
{
- fprintf(stdout, "%s Sorted %d ions into separate groups of %d anions and %d cations.\n",
- SwS, g->nat, nAnions, nCations);
+ fprintf(stdout,
+ "%s Sorted %d ions into separate groups of %d anions and %d cations.\n",
+ SwS,
+ g->nat,
+ nAnions,
+ nCations);
}
for (int ig = eGrpSplit0; ig <= eGrpSplit1; ig++)
{
g = &(s->group[ig]);
- gmx_bcast((g->atomset.numAtomsGlobal()) * sizeof((g->xc_old)[0]), g->xc_old,
- cr->mpi_comm_mygroup);
+ gmx_bcast((g->atomset.numAtomsGlobal()) * sizeof((g->xc_old)[0]), g->xc_old, cr->mpi_comm_mygroup);
}
}
{
if (bVerbose)
{
- fprintf(stderr, "%s Opening output file %s%s\n", SwS, fn,
- restartWithAppending ? " for appending" : "");
+ fprintf(stderr, "%s Opening output file %s%s\n", SwS, fn, restartWithAppending ? " for appending" : "");
}
s->fpout = gmx_fio_fopen(fn, restartWithAppending ? "a" : "w");
for (int ig = 0; ig < s->ngrp; ig++)
{
g = &(s->group[ig]);
- fprintf(s->fpout, "# %s group '%s' contains %d atom%s",
- ig < eSwapFixedGrpNR ? eSwapFixedGrp_names[ig] : "Ion", g->molname,
+ fprintf(s->fpout,
+ "# %s group '%s' contains %d atom%s",
+ ig < eSwapFixedGrpNR ? eSwapFixedGrp_names[ig] : "Ion",
+ g->molname,
static_cast<int>(g->atomset.numAtomsGlobal()),
(g->atomset.numAtomsGlobal() > 1) ? "s" : "");
if (!(eGrpSplit0 == ig || eGrpSplit1 == ig))
{
- fprintf(s->fpout, " with %d atom%s in each molecule of charge %g", g->apm,
- (g->apm > 1) ? "s" : "", g->q);
+ fprintf(s->fpout,
+ " with %d atom%s in each molecule of charge %g",
+ g->apm,
+ (g->apm > 1) ? "s" : "",
+ g->q);
}
fprintf(s->fpout, ".\n");
}
get_center(g->xc, g->m, g->atomset.numAtomsGlobal(), g->center);
if (!restartWithAppending)
{
- fprintf(s->fpout, "# %s group %s-center %5f nm\n", eSwapFixedGrp_names[j],
- DimStr[s->swapdim], g->center[s->swapdim]);
+ fprintf(s->fpout,
+ "# %s group %s-center %5f nm\n",
+ eSwapFixedGrp_names[j],
+ DimStr[s->swapdim],
+ g->center[s->swapdim]);
}
}
}
fprintf(s->fpout, "#\n");
- fprintf(s->fpout, "# Split0 cylinder radius %f nm, up %f nm, down %f nm\n", sc->cyl0r,
- sc->cyl0u, sc->cyl0l);
- fprintf(s->fpout, "# Split1 cylinder radius %f nm, up %f nm, down %f nm\n", sc->cyl1r,
- sc->cyl1u, sc->cyl1l);
+ fprintf(s->fpout,
+ "# Split0 cylinder radius %f nm, up %f nm, down %f nm\n",
+ sc->cyl0r,
+ sc->cyl0u,
+ sc->cyl0l);
+ fprintf(s->fpout,
+ "# Split1 cylinder radius %f nm, up %f nm, down %f nm\n",
+ sc->cyl1r,
+ sc->cyl1u,
+ sc->cyl1l);
fprintf(s->fpout, "#\n");
if (!mdrunOptions.rerun)
fprintf(s->fpout,
"# Coupling constant (number of swap attempt steps to average over): %d "
"(translates to %f ps).\n",
- sc->nAverage, sc->nAverage * sc->nstswap * ir->delta_t);
+ sc->nAverage,
+ sc->nAverage * sc->nstswap * ir->delta_t);
fprintf(s->fpout, "# Threshold is %f\n", sc->threshold);
fprintf(s->fpout, "#\n");
fprintf(s->fpout,
else
{
fprintf(stderr, "%s Determining initial numbers of ions per compartment.\n", SwS);
- get_initial_ioncounts(ir, s, globalState->x.rvec_array(), globalState->box, cr,
- mdrunOptions.rerun);
+ get_initial_ioncounts(
+ ir, s, globalState->x.rvec_array(), globalState->box, cr, mdrunOptions.rerun);
}
/* Prepare (further) checkpoint writes ... */
/* Consistency check */
if (swapstate->nAverage != sc->nAverage)
{
- gmx_fatal(FARGS, "%s Ion count averaging steps mismatch! checkpoint: %d, tpr: %d",
- SwS, swapstate->nAverage, sc->nAverage);
+ gmx_fatal(FARGS,
+ "%s Ion count averaging steps mismatch! checkpoint: %d, tpr: %d",
+ SwS,
+ swapstate->nAverage,
+ sc->nAverage);
}
}
else
gmx_fatal(FARGS,
"Could not get index of %s atom. Compartment contains %d %s molecules before "
"swaps.",
- molname, comp->nMolBefore, molname);
+ molname,
+ comp->nMolBefore,
+ molname);
}
/* Set the distance of this index to infinity such that it won't get selected again in
for (ig = eGrpSplit0; ig <= eGrpSplit1; ig++)
{
g = &(s->group[ig]);
- communicate_group_positions(cr, g->xc, g->xc_shifts, g->xc_eshifts, TRUE, x,
- g->atomset.numAtomsGlobal(), g->atomset.numAtomsLocal(),
+ communicate_group_positions(cr,
+ g->xc,
+ g->xc_shifts,
+ g->xc_eshifts,
+ TRUE,
+ x,
+ g->atomset.numAtomsGlobal(),
+ g->atomset.numAtomsLocal(),
g->atomset.localIndex().data(),
- g->atomset.collectiveIndex().data(), g->xc_old, box);
+ g->atomset.collectiveIndex().data(),
+ g->xc_old,
+ box);
get_center(g->xc, g->m, g->atomset.numAtomsGlobal(), g->center); /* center of split groups == channels */
}
for (ig = eSwapFixedGrpNR; ig < s->ngrp; ig++)
{
g = &(s->group[ig]);
- communicate_group_positions(cr, g->xc, nullptr, nullptr, FALSE, x, g->atomset.numAtomsGlobal(),
- g->atomset.numAtomsLocal(), g->atomset.localIndex().data(),
- g->atomset.collectiveIndex().data(), nullptr, nullptr);
+ communicate_group_positions(cr,
+ g->xc,
+ nullptr,
+ nullptr,
+ FALSE,
+ x,
+ g->atomset.numAtomsGlobal(),
+ g->atomset.numAtomsLocal(),
+ g->atomset.localIndex().data(),
+ g->atomset.collectiveIndex().data(),
+ nullptr,
+ nullptr);
/* Determine how many ions of this type each compartment contains */
sortMoleculesIntoCompartments(g, cr, sc, s, box, step, s->fpout, bRerun, FALSE);
/* Since we here know that we have to perform ion/water position exchanges,
* we now assemble the solvent positions */
g = &(s->group[eGrpSolvent]);
- communicate_group_positions(cr, g->xc, nullptr, nullptr, FALSE, x, g->atomset.numAtomsGlobal(),
- g->atomset.numAtomsLocal(), g->atomset.localIndex().data(),
- g->atomset.collectiveIndex().data(), nullptr, nullptr);
+ communicate_group_positions(cr,
+ g->xc,
+ nullptr,
+ nullptr,
+ FALSE,
+ x,
+ g->atomset.numAtomsGlobal(),
+ g->atomset.numAtomsLocal(),
+ g->atomset.localIndex().data(),
+ g->atomset.collectiveIndex().data(),
+ nullptr,
+ nullptr);
/* Determine how many molecules of solvent each compartment contains */
sortMoleculesIntoCompartments(g, cr, sc, s, box, step, s->fpout, bRerun, TRUE);
if (nswaps && bVerbose)
{
- fprintf(stderr, "%s Performed %d swap%s in step %" PRId64 " for iontype %s.\n", SwS,
- nswaps, nswaps > 1 ? "s" : "", step, g->molname);
+ fprintf(stderr,
+ "%s Performed %d swap%s in step %" PRId64 " for iontype %s.\n",
+ SwS,
+ nswaps,
+ nswaps > 1 ? "s" : "",
+ step,
+ g->molname);
}
}