diff --git a/examples/interface-LAMMPS/H2O_RPBE-D3_Committee/md.lmp b/examples/interface-LAMMPS/H2O_RPBE-D3_Committee/md.lmp index d3d54eae2b..dd87f7c639 100644 --- a/examples/interface-LAMMPS/H2O_RPBE-D3_Committee/md.lmp +++ b/examples/interface-LAMMPS/H2O_RPBE-D3_Committee/md.lmp @@ -9,7 +9,7 @@ clear # Configuration files variable cfgFile string "h2o_8640_liquid_NpT_RPBE-D3.data" # Timesteps -variable numSteps equal 100 +variable numSteps equal 100 variable dt equal 0.0005 # NN variable nnpCutoff equal 6.36 @@ -35,7 +35,7 @@ dump 4a all custom 100 dump.myforce.* id type fx fy fz ############################################################################### # NN ############################################################################### -pair_style nnp dir ${nnpDir} showew no showewsum 10 resetew no maxew 100 calcd 5 maxcd 0.1 cflength 1.8897261328 cfenergy 0.0367493254 emap "1:H,2:O" +pair_style nnp dir ${nnpDir} showew no showewsum 10 resetew no maxew 100 calcd 5 maxcd 0.1 wricd 10 cflength 1.8897261328 cfenergy 0.0367493254 emap "1:H,2:O" pair_coeff * * ${nnpCutoff} ############################################################################### diff --git a/src/interface/LAMMPS/src/USER-NNP/pair_nnp.cpp b/src/interface/LAMMPS/src/USER-NNP/pair_nnp.cpp index 0db8ccaa1c..c4165281eb 100644 --- a/src/interface/LAMMPS/src/USER-NNP/pair_nnp.cpp +++ b/src/interface/LAMMPS/src/USER-NNP/pair_nnp.cpp @@ -82,6 +82,8 @@ void PairNNP::compute(int eflag, int vflag) double* comSumForces = &committeeSumForces[0]; MPI_Bcast(comSumForces, globalNumAtoms, MPI_DOUBLE, 0, MPI_COMM_WORLD); maxcdExceeded = interface.averageComDis(committeeSumForces, maxcd); + if (update->ntimestep % wricd == 0){ + interface.writeCommitteeForces(update->ntimestep);} } else { interface.getForces(atom->f); @@ -132,6 +134,7 @@ void PairNNP::settings(int narg, char **arg) comSize = 1; calcd = 1; maxcd = 0.0; + wricd = 1000; maxcdExceeded = false; resetew = false; cflength = 1.0; @@ -213,6 +216,12 @@ void PairNNP::settings(int narg, char **arg) error->all(FLERR,"Illegal pair_style command"); calcd = utils::inumeric(FLERR,arg[iarg+1],false,lmp); iarg += 2; + // write to file committee disagreement for each wricd step + } else if (strcmp(arg[iarg],"wricd") == 0) { + if (iarg+2 > narg) + error->all(FLERR,"Illegal pair_style command"); + wricd = utils::inumeric(FLERR,arg[iarg+1],false,lmp); + iarg += 2; // committee disagreement threshold } else if (strcmp(arg[iarg],"maxcd") == 0) { if (iarg+2 > narg) diff --git a/src/interface/LAMMPS/src/USER-NNP/pair_nnp.h b/src/interface/LAMMPS/src/USER-NNP/pair_nnp.h index 51d7e2a6a6..b0cb1862bd 100644 --- a/src/interface/LAMMPS/src/USER-NNP/pair_nnp.h +++ b/src/interface/LAMMPS/src/USER-NNP/pair_nnp.h @@ -49,6 +49,7 @@ class PairNNP : public Pair { int globalNumAtoms; int comSize; int calcd; + int wricd; long numExtrapolationWarningsTotal; long numExtrapolationWarningsSummary; double cflength; diff --git a/src/libnnpif/LAMMPS/InterfaceLammps.cpp b/src/libnnpif/LAMMPS/InterfaceLammps.cpp index cdf7c28269..5a8def0887 100644 --- a/src/libnnpif/LAMMPS/InterfaceLammps.cpp +++ b/src/libnnpif/LAMMPS/InterfaceLammps.cpp @@ -457,7 +457,7 @@ bool InterfaceLammps::averageComDis(std::vector const& committeeSumForce ai->aveComDis = sqrt(ai->aveComDis/(3*(ai->numNeighborsCom+1))); if (ai->aveComDis > maxcd){ maxcdExceeded = true; - outfile.open("committee-force.txt", std::ios_base::app); + outfile.open("committee.stop", std::ios_base::app); outfile << strpr("%i %16.6E %i\n", ai->tag, ai->aveComDis, ai->numNeighborsCom+1); outfile.close(); } @@ -799,4 +799,19 @@ void InterfaceLammps::writeEnergyCommittee() const outfile.close(); return; +} + +void InterfaceLammps::writeCommitteeForces(std::size_t const& timestep) +{ + ofstream outfile; + outfile.open(strpr("committee.%d", timestep).c_str(), std::ios_base::app); + Atom* ai = NULL; + for (size_t i = 0; i < structure.atoms.size(); ++i) + { + ai = &(structure.atoms.at(i)); + outfile << strpr("%i %16.6E %i\n", ai->tag, ai->aveComDis, ai->numNeighborsCom+1); + } + outfile.close(); + + return; } \ No newline at end of file diff --git a/src/libnnpif/LAMMPS/InterfaceLammps.h b/src/libnnpif/LAMMPS/InterfaceLammps.h index ce510b6df9..f50fa213b4 100644 --- a/src/libnnpif/LAMMPS/InterfaceLammps.h +++ b/src/libnnpif/LAMMPS/InterfaceLammps.h @@ -229,6 +229,11 @@ class InterfaceLammps : public Mode /** Write committee energies and committee disagreement to file. */ void writeEnergyCommittee() const; + /** Write committee force disagreement to file. + * + * @param[in] timestep Lammps molecular dynamics timestep. + */ + void writeCommitteeForces(std::size_t const& timestep); protected: /// Process rank.