apply clang-format
This commit is contained in:
@ -22,21 +22,21 @@
|
||||
Version 1.0
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
#include "fix_pimdb_langevin.h"
|
||||
#include "universe.h"
|
||||
#include "comm.h"
|
||||
#include "force.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "comm.h"
|
||||
#include "domain.h"
|
||||
#include "update.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include <algorithm>
|
||||
#include "force.h"
|
||||
#include "memory.h"
|
||||
#include "universe.h"
|
||||
#include "update.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
|
||||
@ -46,44 +46,46 @@ FixPIMDBLangevin::FixPIMDBLangevin(LAMMPS *lmp, int narg, char **arg) :
|
||||
FixPIMDLangevin(lmp, narg, filtered_args = filter_args(narg, arg)), filtered_narg(narg),
|
||||
nbosons(atom->nlocal), bosonic_exchange(lmp, atom->nlocal, np, universe->me, true, false)
|
||||
{
|
||||
synch_energies = true;
|
||||
// Loop over the arguments with i++ instead of i+=2 like the parent,
|
||||
// because the parent's loop has i++ inside some if blocks.
|
||||
for (int i = 3; i < narg - 1; i++) {
|
||||
if ((strcmp(arg[i], "method") == 0) && (strcmp(arg[i+1], "pimd") != 0)) {
|
||||
error->universe_all(FLERR, "Method not supported in fix pimdb/langevin; only method PIMD");
|
||||
}
|
||||
else if (strcmp(arg[i], "scale") == 0) {
|
||||
error->universe_all(FLERR, "The scale parameter of the PILE_L thermostat is not supported for pimdb, and should be removed.");
|
||||
}
|
||||
else if ((strcmp(arg[i], "iso") == 0) || (strcmp(arg[i], "aniso") == 0) || (strcmp(arg[i], "barostat") == 0) || (strcmp(arg[i], "taup") == 0)) {
|
||||
error->universe_all(FLERR, "Barostat parameters are not available for pimdb.");
|
||||
}
|
||||
else if (strcmp(arg[i], "esynch") == 0) {
|
||||
if (strcmp(arg[i + 1], "yes") == 0) {
|
||||
synch_energies = true;
|
||||
}
|
||||
else if (strcmp(arg[i + 1], "no") == 0) {
|
||||
synch_energies = false;
|
||||
}
|
||||
else {
|
||||
error->universe_all(FLERR, "The esynch parameter can only receive yes or no!");
|
||||
}
|
||||
}
|
||||
synch_energies = true;
|
||||
// Loop over the arguments with i++ instead of i+=2 like the parent,
|
||||
// because the parent's loop has i++ inside some if blocks.
|
||||
for (int i = 3; i < narg - 1; i++) {
|
||||
if ((strcmp(arg[i], "method") == 0) && (strcmp(arg[i + 1], "pimd") != 0)) {
|
||||
error->universe_all(FLERR, "Method not supported in fix pimdb/langevin; only method PIMD");
|
||||
} else if (strcmp(arg[i], "scale") == 0) {
|
||||
error->universe_all(FLERR,
|
||||
"The scale parameter of the PILE_L thermostat is not supported for "
|
||||
"pimdb, and should be removed.");
|
||||
} else if ((strcmp(arg[i], "iso") == 0) || (strcmp(arg[i], "aniso") == 0) ||
|
||||
(strcmp(arg[i], "barostat") == 0) || (strcmp(arg[i], "taup") == 0)) {
|
||||
error->universe_all(FLERR, "Barostat parameters are not available for pimdb.");
|
||||
} else if (strcmp(arg[i], "esynch") == 0) {
|
||||
if (strcmp(arg[i + 1], "yes") == 0) {
|
||||
synch_energies = true;
|
||||
} else if (strcmp(arg[i + 1], "no") == 0) {
|
||||
synch_energies = false;
|
||||
} else {
|
||||
error->universe_all(FLERR, "The esynch parameter can only receive yes or no!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fmmode != PHYSICAL) {
|
||||
error->universe_all(FLERR, "The only available fmmode for pimdb is physical, please remove the fmmode keyword.");
|
||||
}
|
||||
if (ensemble != NVE && ensemble != NVT) {
|
||||
error->universe_all(FLERR, "The only available ensembles for pimdb are nve and nvt, please choose one of these ensembles.");
|
||||
}
|
||||
if (fmmode != PHYSICAL) {
|
||||
error->universe_all(
|
||||
FLERR,
|
||||
"The only available fmmode for pimdb is physical, please remove the fmmode keyword.");
|
||||
}
|
||||
if (ensemble != NVE && ensemble != NVT) {
|
||||
error->universe_all(FLERR,
|
||||
"The only available ensembles for pimdb are nve and nvt, please choose one "
|
||||
"of these ensembles.");
|
||||
}
|
||||
|
||||
method = PIMD;
|
||||
method = PIMD;
|
||||
|
||||
size_vector = 6;
|
||||
size_vector = 6;
|
||||
|
||||
memory->create(f_tag_order, nbosons, 3, "FixPIMDBLangevin:f_tag_order");
|
||||
memory->create(f_tag_order, nbosons, 3, "FixPIMDBLangevin:f_tag_order");
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -115,74 +117,72 @@ char **FixPIMDBLangevin::filter_args(int narg, char **arg)
|
||||
|
||||
void FixPIMDBLangevin::prepare_coordinates()
|
||||
{
|
||||
inter_replica_comm(atom->x);
|
||||
double ff = fbond * atom->mass[atom->type[0]];
|
||||
int nlocal = atom->nlocal;
|
||||
double* me_bead_positions = *(atom->x);
|
||||
double* last_bead_positions = &bufsortedall[x_last * nlocal][0];
|
||||
double* next_bead_positions = &bufsortedall[x_next * nlocal][0];
|
||||
inter_replica_comm(atom->x);
|
||||
double ff = fbond * atom->mass[atom->type[0]];
|
||||
int nlocal = atom->nlocal;
|
||||
double *me_bead_positions = *(atom->x);
|
||||
double *last_bead_positions = &bufsortedall[x_last * nlocal][0];
|
||||
double *next_bead_positions = &bufsortedall[x_next * nlocal][0];
|
||||
|
||||
bosonic_exchange.prepare_with_coordinates(me_bead_positions,
|
||||
last_bead_positions, next_bead_positions,
|
||||
beta_np, ff);
|
||||
bosonic_exchange.prepare_with_coordinates(me_bead_positions, last_bead_positions,
|
||||
next_bead_positions, beta_np, ff);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixPIMDBLangevin::spring_force() {
|
||||
void FixPIMDBLangevin::spring_force()
|
||||
{
|
||||
|
||||
for (int i = 0; i < nbosons; i++) {
|
||||
f_tag_order[i][0] = 0.0;
|
||||
f_tag_order[i][1] = 0.0;
|
||||
f_tag_order[i][2] = 0.0;
|
||||
}
|
||||
bosonic_exchange.spring_force(f_tag_order);
|
||||
for (int i = 0; i < nbosons; i++) {
|
||||
f_tag_order[i][0] = 0.0;
|
||||
f_tag_order[i][1] = 0.0;
|
||||
f_tag_order[i][2] = 0.0;
|
||||
}
|
||||
bosonic_exchange.spring_force(f_tag_order);
|
||||
|
||||
double** f = atom->f;
|
||||
tagint* tag = atom->tag;
|
||||
for (int i = 0; i < nbosons; i++) {
|
||||
f[i][0] += f_tag_order[tag[i] - 1][0];
|
||||
f[i][1] += f_tag_order[tag[i] - 1][1];
|
||||
f[i][2] += f_tag_order[tag[i] - 1][2];
|
||||
}
|
||||
double **f = atom->f;
|
||||
tagint *tag = atom->tag;
|
||||
for (int i = 0; i < nbosons; i++) {
|
||||
f[i][0] += f_tag_order[tag[i] - 1][0];
|
||||
f[i][1] += f_tag_order[tag[i] - 1][1];
|
||||
f[i][2] += f_tag_order[tag[i] - 1][2];
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixPIMDBLangevin::compute_spring_energy() {
|
||||
se_bead = bosonic_exchange.get_bead_spring_energy();
|
||||
void FixPIMDBLangevin::compute_spring_energy()
|
||||
{
|
||||
se_bead = bosonic_exchange.get_bead_spring_energy();
|
||||
|
||||
if (synch_energies) {
|
||||
MPI_Allreduce(&se_bead, &total_spring_energy, 1, MPI_DOUBLE, MPI_SUM, universe->uworld);
|
||||
total_spring_energy /= universe->procs_per_world[universe->iworld];
|
||||
}
|
||||
else {
|
||||
total_spring_energy = 0;
|
||||
}
|
||||
if (synch_energies) {
|
||||
MPI_Allreduce(&se_bead, &total_spring_energy, 1, MPI_DOUBLE, MPI_SUM, universe->uworld);
|
||||
total_spring_energy /= universe->procs_per_world[universe->iworld];
|
||||
} else {
|
||||
total_spring_energy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixPIMDBLangevin::compute_t_prim()
|
||||
{
|
||||
if (synch_energies) {
|
||||
double prim = bosonic_exchange.prim_estimator();
|
||||
MPI_Allreduce(&prim, &t_prim, 1, MPI_DOUBLE, MPI_SUM, universe->uworld);
|
||||
}
|
||||
else {
|
||||
t_prim = bosonic_exchange.prim_estimator();
|
||||
}
|
||||
if (synch_energies) {
|
||||
double prim = bosonic_exchange.prim_estimator();
|
||||
MPI_Allreduce(&prim, &t_prim, 1, MPI_DOUBLE, MPI_SUM, universe->uworld);
|
||||
} else {
|
||||
t_prim = bosonic_exchange.prim_estimator();
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
double FixPIMDBLangevin::compute_vector(int n)
|
||||
{
|
||||
if (0 <= n && n < 6) {
|
||||
return FixPIMDLangevin::compute_vector(n);
|
||||
}
|
||||
else {
|
||||
error->universe_all(FLERR, "Fix only has 6 outputs!");
|
||||
}
|
||||
return 0.0;
|
||||
if (0 <= n && n < 6) {
|
||||
return FixPIMDLangevin::compute_vector(n);
|
||||
} else {
|
||||
error->universe_all(FLERR, "Fix only has 6 outputs!");
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user