incorporate compute_pe_e3b into compute_pair

This commit is contained in:
Steven Strong
2019-05-08 09:05:09 -05:00
parent 6c3cae8823
commit da75fc3eaa
13 changed files with 19 additions and 215 deletions

View File

@ -91,7 +91,6 @@ KOKKOS, o = USER-OMP, t = OPT.
"pe/atom"_compute_pe_atom.html,
"pe/mol/tally"_compute_tally.html,
"pe/tally"_compute_tally.html,
"pe/e3b"_compute_pe_e3b.html,
"plasticity/atom"_compute_plasticity_atom.html,
"pressure"_compute_pressure.html,
"pressure/cylinder"_compute_pressure_cylinder.html,

View File

@ -240,7 +240,6 @@ compute"_Commands_compute.html doc page are followed by one or more of
"pe/atom"_compute_pe_atom.html - potential energy for each atom
"pe/mol/tally"_compute_tally.html -
"pe/tally"_compute_tally.html -
"pe/e3b"_compute_pe_e3b.html - potential energy from pair_style e3b
"plasticity/atom"_compute_plasticity_atom.html - Peridynamic plasticity for each atom
"pressure"_compute_pressure.html - total pressure and pressure tensor
"pressure/cylinder"_compute_pressure_cylinder.html -

View File

@ -1,60 +0,0 @@
"LAMMPS WWW Site"_lws - "LAMMPS Documentation"_ld - "LAMMPS Commands"_lc :c
:link(lws,http://lammps.sandia.gov)
:link(ld,Manual.html)
:link(lc,Commands_all.html)
:line
compute pe/e3b command :h3
[Syntax:]
compute ID group-ID pe/e3b :pre
ID, group-ID are documented in "compute"_compute.html command
pe/e3b = style name of this compute command :ul
[Examples:]
compute 1 all pe/e3b :pre
[Description:]
Define a computation that calculates the contribution of "pair_style e3b"_pair_e3b.html to the potential energy.
The specified group must be "all".
See the "compute pe/atom"_compute_pe_atom.html command if you want per-atom
energies.
These per-atom values could be summed for a group of atoms via the "compute reduce"_compute_reduce.html command.
The "pair_style e3b"_pair_e3b.html potential is composed of 4 terms.
This compute calculates the total e3b contribution to the energy as well as each of the four terms.
The four terms are stored as a 4-element vector in the order pe_Ea, pe_Eb, pe_Ec, pe_E2.
See "pair_style e3b"_pair_e3b.html for more details, and an example script can be found in the examples/USER/e3b directory.
:line
[Output info:]
This compute calculates a global scalar (the total e3b energy) and a global
vector of length 4 (the four energy terms), which can be accessed by indices
1-4. These values can be used by any command that uses global scalar
or vector values from a compute as input. See the "Howto
output"_Howto_output.html doc page for an overview of LAMMPS output
options.
The scalar and vector values calculated by this compute are
"extensive" and in energy
"units"_units.html.
[Restrictions:]
This compute must be used with "pair_style e3b"_pair_e3b.html.
[Related commands:]
"pair_style e3b"_pair_e3b.html,
"compute pe"_compute_pe.html,
"compute pe/atom"_compute_pe_atom.html
[Default:] none

View File

@ -66,7 +66,6 @@ Computes :h1
compute_pair_local
compute_pe
compute_pe_atom
compute_pe_e3b
compute_plasticity_atom
compute_pressure
compute_pressure_cylinder

View File

@ -86,8 +86,8 @@ This estimate defaults to 10 and can be changed using the {neigh} keyword, which
If the neigh setting is too small, the simulation will fail with the error "neigh is too small".
If the neigh setting is too large, the pair style will use more memory than necessary.
This pair style makes 4 different contributions to the potential energy from the E2, Ea, Eb, and Ec terms above.
The value of each of these terms can be computed using "compute pe/e3b"_compute_pe_e3b.html.
This pair style tallies a breakdown of the total E3B potential energy into sub-categories, which can be accessed via the "compute pair"_compute_pair.html command as a vector of values of length 4.
The 4 values correspond to the terms in the first equation above: the E2 term, the Ea term, the Eb term, and the Ec term.
See the examples/USER/e3b directory for a complete example script.
@ -124,7 +124,7 @@ The {preset} keyword currently only works with real, metal, si, and cgs "units"_
[Related commands:]
"pair_coeff"_pair_coeff.html, "compute pe/e3b"_compute_pe_e3b.html
"pair_coeff"_pair_coeff.html, "compute pair"_compute_pair.html
[Default:]

View File

@ -1,6 +1,6 @@
The input script in.lammps simulates bulk water using the 2015 E3B potential.
This script also demonstrates the use of compute pe/e3b to calculate the
This script also demonstrates the use of compute pair to calculate the
potential energy contribution of the e3b pair style. These potential energy
contributions can be found in the output file e3b.txt. See the LAMMPS
documentation for more details.

View File

@ -74,9 +74,9 @@ velocity all create ${myT} 15856 dist gaussian rot yes mom yes
run 0
velocity all scale ${myT}
compute e3b all pe/e3b
compute e3b all pair e3b
fix e3b all ave/time 1 1 ${thermo_rate} c_e3b c_e3b[*] &
file e3b.txt title2 "step pe_e3b pe_ea pe_eb pe_ec pe_e2"
file e3b.txt title2 "step pe_e3b pe_e2 pe_ea pe_eb pe_ec"
#############################################################################
#equilibrate bulk water at NVT

7
src/.gitignore vendored
View File

@ -309,8 +309,6 @@
/compute_meso_t_atom.h
/compute_msd_nongauss.cpp
/compute_msd_nongauss.h
/compute_pe_e3b.cpp
/compute_pe_e3b.h
/compute_pe_tally.cpp
/compute_pe_tally.h
/compute_plasticity_atom.cpp
@ -794,6 +792,10 @@
/pair_eam_cd.h
/pair_eam_fs.cpp
/pair_eam_fs.h
/fix_electron_stopping.cpp
/fix_electron_stopping.h
/pair_lebedeva_z.cpp
/pair_lebedeva_z.h
/pair_lj_expand_coul_long.cpp
/pair_lj_expand_coul_long.h
/pair_edip.cpp
@ -1242,4 +1244,3 @@
/pair_smtbq.h
/pair_vashishta*.cpp
/pair_vashishta*.h

View File

@ -29,7 +29,6 @@ bond_style harmonic/shift/cut, Carsten Svaneborg, science at zqex.dk, 8 Aug 11
compute ackland/atom, Gerolf Ziegenhain, gerolf at ziegenhain.com, 4 Oct 2007
compute basal/atom, Christopher Barrett, cdb333 at cavs.msstate.edu, 3 Mar 2013
compute cnp/atom, Paulo Branicio (USC), branicio at usc.edu, 31 May 2017
compute pe/e3b, Steven Strong (U Chicago), stevene.strong at gmail dot com, 16 Apr 19
compute entropy/atom, Pablo Piaggi (EPFL), pablo.piaggi at epfl.ch, 15 June 2018
compute pressure/cylinder, Cody K. Addington (NCSU), , 2 Oct 2018
compute stress/mop, Romain Vermorel (U Pau) & Laurent Joly (U Lyon), romain.vermorel at univ-pau.fr & ljoly.ulyon at gmail.com, 5 Sep 18

View File

@ -1,86 +0,0 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
contributing author: Steven E Strong
stevene.strong at gmail dot com
------------------------------------------------------------------------- */
#include "compute_pe_e3b.h"
#include "pair_e3b.h"
#include "pair.h"
#include "update.h"
#include "error.h"
#include "force.h"
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
ComputePEE3B::ComputePEE3B(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg), e3b(NULL)
{
// 0 1 2
//compute ID grp pe/e3b
if (narg != 3) error->all(FLERR,"Illegal compute pe/e3b command");
scalar_flag = 1;
vector_flag = 1;
size_vector = 4; //etotA,etotB,etotC,etot2
extvector = extscalar = 1;
timeflag = 1;
peflag = 1; // we need Pair::ev_tally() to be run
invoked_vector = invoked_scalar = -1;
vector = new double[size_vector];
}
/* ---------------------------------------------------------------------- */
ComputePEE3B::~ComputePEE3B()
{
delete[] vector;
}
/* ---------------------------------------------------------------------- */
void ComputePEE3B::init() {
Pair *pair = force->pair_match("e3b",false,0);
if (pair==NULL)
error->all(FLERR,"This compute must be used with pair_style e3b");
e3b = (PairE3B *) pair;
if (e3b==NULL)
error->all(FLERR,"something went wrong");
}
/* ---------------------------------------------------------------------- */
void ComputePEE3B::compute_vector()
{
invoked_vector = update->ntimestep;
if (update->eflag_global != invoked_scalar)
error->all(FLERR,"Energy was not tallied on needed timestep");
// sum energies across procs
MPI_Allreduce(e3b->etot,vector,4,MPI_DOUBLE,MPI_SUM,world);
}
double ComputePEE3B::compute_scalar() {
invoked_scalar = update->ntimestep;
if (invoked_scalar != invoked_vector)
compute_vector();
scalar = vector[0]+vector[1]+vector[2]+vector[3];
return scalar;
}

View File

@ -1,45 +0,0 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifdef COMPUTE_CLASS
ComputeStyle(pe/e3b,ComputePEE3B)
#else
#ifndef LMP_COMPUTE_PEE3B_H
#define LMP_COMPUTE_PEE3B_H
#include "compute.h"
namespace LAMMPS_NS {
class ComputePEE3B : public Compute {
public:
ComputePEE3B(class LAMMPS *, int, char **);
virtual ~ComputePEE3B();
void init();
double compute_scalar();
void compute_vector();
private:
class PairE3B *e3b;
};
}
#endif
#endif

View File

@ -48,6 +48,8 @@ PairE3B::PairE3B(LAMMPS *lmp) : Pair(lmp),pairPerAtom(10)
single_enable = 0;
restartinfo = 0;
one_coeff = 1;
nextra=4; //store and tally pot energy terms eA, eB, eC, and e2
pvector = new double[nextra];
allocatedE3B = false;
pairO = NULL;
@ -78,6 +80,8 @@ PairE3B::~PairE3B()
memory->destroy(fpair3);
memory->destroy(sumExp);
}
delete[] pvector;
}
/* ---------------------------------------------------------------------- */
@ -99,7 +103,7 @@ void PairE3B::compute(int eflag, int vflag)
memset(sumExp,0.0,nbytes);
evdwl = 0.0;
etot[0]=etot[1]=etot[2]=etot[3]=0.0;
pvector[0]=pvector[1]=pvector[2]=pvector[3]=0.0;
if (eflag || vflag) ev_setup(eflag,vflag);
else evflag = vflag_fdotr = 0;
@ -161,7 +165,7 @@ void PairE3B::compute(int eflag, int vflag)
if (evflag) {
ev_tally(i,j,nlocal,newton_pair,tmpexp,0.0,fpair,delx,dely,delz);
etot[3] += tmpexp;
pvector[0] += tmpexp;
}
} //end if rsq<rc2sq
@ -282,7 +286,7 @@ void PairE3B::compute(int eflag, int vflag)
evdwl = partA*exps[ii][kk][hh]*0.5; //mult by exp on this H
ev_tally(i,j,nlocal,newton_pair,evdwl, 0.0,fpair,
del3[ii][kk][hh][0],del3[ii][kk][hh][1],del3[ii][kk][hh][2]);
etot[0] += evdwl;
pvector[1] += evdwl;
}
//type B
@ -302,7 +306,7 @@ void PairE3B::compute(int eflag, int vflag)
evdwl = partB*exps[ii][kk][hh]*0.5; //mult by exp on this H
ev_tally(i,j,nlocal,newton_pair,evdwl, 0.0,fpair,
del3[ii][kk][hh][0],del3[ii][kk][hh][1],del3[ii][kk][hh][2]);
etot[1] += evdwl;
pvector[2] += evdwl;
}
//type C
@ -322,7 +326,7 @@ void PairE3B::compute(int eflag, int vflag)
evdwl = partC*exps[ii][kk][hh]*0.5; //mult by exp on this H
ev_tally(i,j,nlocal,newton_pair,evdwl, 0.0,fpair,
del3[ii][kk][hh][0],del3[ii][kk][hh][1],del3[ii][kk][hh][2]);
etot[2] += evdwl;
pvector[3] += evdwl;
}
} //end for hh in NUMH
} //end for kk in NUMO

View File

@ -21,7 +21,6 @@ PairStyle(e3b,PairE3B)
#define LMP_PAIR_E3B_H
#include "pair.h"
#include "compute_pe_e3b.h"
namespace LAMMPS_NS {
@ -35,9 +34,6 @@ class PairE3B : public Pair {
virtual double init_one(int, int);
virtual void init_style();
//allow compute pe/e3b to access etot vector
friend void ComputePEE3B::compute_vector();
protected:
//potential parameters
int typeO;
@ -57,8 +53,6 @@ protected:
size_t nbytes; //size of sumExp array in bytes
int natoms; //to make sure number of atoms is constant
double etot[4]; //etotA,etotB,etotC,etot2
virtual void allocate();
void allocateE3B();
bool allocatedE3B;