add support for bond/angle/dihedral/improper plugins
This commit is contained in:
@ -53,12 +53,16 @@ target_link_libraries(nve2plugin PRIVATE lammps)
|
||||
add_library(helloplugin MODULE helloplugin.cpp)
|
||||
target_link_libraries(helloplugin PRIVATE lammps)
|
||||
|
||||
set_target_properties(morse2plugin nve2plugin helloplugin PROPERTIES
|
||||
add_library(zero2plugin MODULE zero2plugin.cpp pair_zero2.cpp bond_zero2.cpp
|
||||
angle_zero2.cpp dihedral_zero2.cpp improper_zero2.cpp)
|
||||
target_link_libraries(zero2plugin PRIVATE lammps)
|
||||
|
||||
set_target_properties(morse2plugin nve2plugin helloplugin zero2plugin PROPERTIES
|
||||
PREFIX ""
|
||||
LINK_FLAGS "-rdynamic")
|
||||
|
||||
# MacOS seems to need this
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
||||
set_target_properties(morse2plugin nve2plugin helloplugin PROPERTIES
|
||||
set_target_properties(morse2plugin nve2plugin helloplugin zero2plugin PROPERTIES
|
||||
LINK_FLAGS "-Wl,-undefined,dynamic_lookup")
|
||||
endif()
|
||||
|
||||
@ -1,30 +1,6 @@
|
||||
CXX=mpicxx
|
||||
CXXFLAGS=-I../../src -Wall -Wextra -O3 -fPIC -I../../src/USER-OMP -fopenmp
|
||||
LD=$(CXX) -shared -rdynamic -fopenmp
|
||||
DSOEXT=.so
|
||||
|
||||
default: morse2plugin.so nve2plugin.so helloplugin.so
|
||||
|
||||
helloplugin.so: helloplugin.o
|
||||
$(LD) -o $@ $^
|
||||
|
||||
morse2plugin.so: morse2plugin.o pair_morse2.o pair_morse2_omp.o
|
||||
$(LD) -o $@ $^
|
||||
|
||||
nve2plugin.so: nve2plugin.o fix_nve2.o
|
||||
$(LD) -o $@ $^
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) -o $@ $(CXXFLAGS) -c $<
|
||||
|
||||
helloplugin.o: helloplugin.cpp
|
||||
|
||||
pair_morse2.o: pair_morse2.cpp pair_morse2.h
|
||||
pair_morse2_omp.o: pair_morse2_omp.cpp pair_morse2_omp.h pair_morse2.h
|
||||
morse2plugin.o: morse2plugin.cpp pair_morse2.h pair_morse2_omp.h
|
||||
|
||||
fix_nve2.o: fix_nve2.cpp fix_nve2.h
|
||||
nve2plugin.o: nve2plugin.cpp fix_nve2.h
|
||||
|
||||
clean:
|
||||
rm -rf *~ *.so *.dylib *.o log.lammps CMakeCache.txt CMakeFiles
|
||||
|
||||
include Makefile.common
|
||||
|
||||
36
examples/plugins/Makefile.common
Normal file
36
examples/plugins/Makefile.common
Normal file
@ -0,0 +1,36 @@
|
||||
default: morse2plugin$(DSOEXT) nve2plugin$(DSOEXT) helloplugin$(DSOEXT) zero2plugin$(DSOEXT)
|
||||
|
||||
helloplugin$(DSOEXT): helloplugin.o
|
||||
$(LD) -o $@ $^
|
||||
|
||||
morse2plugin$(DSOEXT): morse2plugin.o pair_morse2.o pair_morse2_omp.o
|
||||
$(LD) -o $@ $^
|
||||
|
||||
nve2plugin$(DSOEXT): nve2plugin.o fix_nve2.o
|
||||
$(LD) -o $@ $^
|
||||
|
||||
zero2plugin$(DSOEXT): zero2plugin.o pair_zero2.o bond_zero2.o angle_zero2.o dihedral_zero2.o improper_zero2.o
|
||||
$(LD) -o $@ $^
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) -o $@ $(CXXFLAGS) -c $<
|
||||
|
||||
helloplugin.o: helloplugin.cpp
|
||||
|
||||
pair_morse2.o: pair_morse2.cpp pair_morse2.h
|
||||
pair_morse2_omp.o: pair_morse2_omp.cpp pair_morse2_omp.h pair_morse2.h
|
||||
morse2plugin.o: morse2plugin.cpp pair_morse2.h pair_morse2_omp.h
|
||||
|
||||
fix_nve2.o: fix_nve2.cpp fix_nve2.h
|
||||
nve2plugin.o: nve2plugin.cpp fix_nve2.h
|
||||
|
||||
pair_zero2.o: pair_zero2.cpp pair_zero2.h
|
||||
bond_zero2.o: bond_zero2.cpp bond_zero2.h
|
||||
angle_zero2.o: angle_zero2.cpp angle_zero2.h
|
||||
dihedral_zero2.o: dihedral_zero2.cpp dihedral_zero2.h
|
||||
improper_zero2.o: improper_zero2.cpp improper_zero2.h
|
||||
zero2plugin.o: zero2plugin.cpp pair_zero2.h bond_zero2.h angle_zero2.h dihedral_zero2.h
|
||||
|
||||
clean:
|
||||
rm -rf *~ *.so *.dylib *.o log.lammps CMakeCache.txt CMakeFiles
|
||||
|
||||
@ -1,30 +1,6 @@
|
||||
CXX=mpicxx
|
||||
CXXFLAGS=-I../../src -Wall -Wextra -O3 -fPIC -I../../src/USER-OMP
|
||||
CXXFLAGS=-I../../src -Wall -Wextra -O3 -fPIC -I../../src/USER-OMP
|
||||
LD=$(CXX) -bundle -rdynamic -Wl,-undefined,dynamic_lookup
|
||||
DSOEXT=.dylib
|
||||
|
||||
default: morse2plugin.dylib nve2plugin.dylib helloplugin.dylib
|
||||
|
||||
helloplugin.dylib: helloplugin.o
|
||||
$(LD) -o $@ $^
|
||||
|
||||
morse2plugin.dylib: morse2plugin.o pair_morse2.o pair_morse2_omp.o
|
||||
$(LD) -o $@ $^
|
||||
|
||||
nve2plugin.dylib: nve2plugin.o fix_nve2.o
|
||||
$(LD) -o $@ $^
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) -o $@ $(CXXFLAGS) -c $<
|
||||
|
||||
helloplugin.o: helloplugin.cpp
|
||||
|
||||
pair_morse2.o: pair_morse2.cpp pair_morse2.h
|
||||
pair_morse2_omp.o: pair_morse2_omp.cpp pair_morse2_omp.h pair_morse2.h
|
||||
morse2plugin.o: morse2plugin.cpp pair_morse2.h pair_morse2_omp.h
|
||||
|
||||
fix_nve2.o: fix_nve2.cpp fix_nve2.h
|
||||
nve2plugin.o: nve2plugin.cpp fix_nve2.h
|
||||
|
||||
clean:
|
||||
rm -rf *~ *.dylib *.dylib *.o log.lammps CMakeCache.txt CMakeFiles
|
||||
|
||||
include Makefile.common
|
||||
|
||||
@ -1,30 +1,6 @@
|
||||
CXX=g++
|
||||
CXXFLAGS=-I../../src -I../../src/STUBS -Wall -Wextra -O3 -fPIC -I../../src/USER-OMP -fopenmp
|
||||
LD=$(CXX) -shared -rdynamic -fopenmp
|
||||
DSOEXT=.so
|
||||
|
||||
default: morse2plugin.so nve2plugin.so helloplugin.so
|
||||
|
||||
helloplugin.so: helloplugin.o
|
||||
$(LD) -o $@ $^
|
||||
|
||||
morse2plugin.so: morse2plugin.o pair_morse2.o pair_morse2_omp.o
|
||||
$(LD) -o $@ $^
|
||||
|
||||
nve2plugin.so: nve2plugin.o fix_nve2.o
|
||||
$(LD) -o $@ $^
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) -o $@ $(CXXFLAGS) -c $<
|
||||
|
||||
helloplugin.o: helloplugin.cpp
|
||||
|
||||
pair_morse2.o: pair_morse2.cpp pair_morse2.h
|
||||
pair_morse2_omp.o: pair_morse2_omp.cpp pair_morse2_omp.h pair_morse2.h
|
||||
morse2plugin.o: morse2plugin.cpp pair_morse2.h pair_morse2_omp.h
|
||||
|
||||
fix_nve2.o: fix_nve2.cpp fix_nve2.h
|
||||
nve2plugin.o: nve2plugin.cpp fix_nve2.h
|
||||
|
||||
clean:
|
||||
rm -rf *~ *.so *.dylib *.o log.lammps CMakeCache.txt CMakeFiles
|
||||
|
||||
include Makefile.common
|
||||
|
||||
152
examples/plugins/angle_zero2.cpp
Normal file
152
examples/plugins/angle_zero2.cpp
Normal file
@ -0,0 +1,152 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://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: Carsten Svaneborg (SDU)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "angle_zero2.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "comm.h"
|
||||
#include "math_const.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
AngleZero2::AngleZero2(LAMMPS *lmp) : Angle(lmp), coeffflag(1) {}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
AngleZero2::~AngleZero2()
|
||||
{
|
||||
if (allocated && !copymode) {
|
||||
memory->destroy(setflag);
|
||||
memory->destroy(theta0);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AngleZero2::compute(int eflag, int vflag)
|
||||
{
|
||||
ev_init(eflag,vflag);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AngleZero2::settings(int narg, char **arg)
|
||||
{
|
||||
if ((narg != 0) && (narg != 1))
|
||||
error->all(FLERR,"Illegal angle_style command");
|
||||
|
||||
if (narg == 1) {
|
||||
if (strcmp("nocoeff",arg[0]) == 0) coeffflag=0;
|
||||
else error->all(FLERR,"Illegal angle_style command");
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AngleZero2::allocate()
|
||||
{
|
||||
allocated = 1;
|
||||
int n = atom->nangletypes;
|
||||
|
||||
memory->create(theta0,n+1,"angle:theta0");
|
||||
memory->create(setflag,n+1,"angle:setflag");
|
||||
for (int i = 1; i <= n; i++) setflag[i] = 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
set coeffs for one or more types
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AngleZero2::coeff(int narg, char **arg)
|
||||
{
|
||||
if ((narg < 1) || (coeffflag && narg > 2))
|
||||
error->all(FLERR,"Incorrect args for angle coefficients");
|
||||
|
||||
if (!allocated) allocate();
|
||||
|
||||
int ilo,ihi;
|
||||
utils::bounds(FLERR,arg[0],1,atom->nangletypes,ilo,ihi,error);
|
||||
|
||||
double theta0_one = 0.0;
|
||||
if (coeffflag && (narg == 2))
|
||||
theta0_one = utils::numeric(FLERR,arg[1],false,lmp);
|
||||
|
||||
// convert theta0 from degrees to radians
|
||||
|
||||
int count = 0;
|
||||
for (int i = ilo; i <= ihi; i++) {
|
||||
setflag[i] = 1;
|
||||
theta0[i] = theta0_one/180.0 * MY_PI;
|
||||
count++;
|
||||
}
|
||||
|
||||
if (count == 0) error->all(FLERR,"Incorrect args for angle coefficients");
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
double AngleZero2::equilibrium_angle(int i)
|
||||
{
|
||||
return theta0[i];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
proc 0 writes out coeffs to restart file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AngleZero2::write_restart(FILE *fp) {
|
||||
fwrite(&theta0[1],sizeof(double),atom->nangletypes,fp);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
proc 0 reads coeffs from restart file, bcasts them
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AngleZero2::read_restart(FILE *fp)
|
||||
{
|
||||
allocate();
|
||||
|
||||
if (comm->me == 0) {
|
||||
utils::sfread(FLERR,&theta0[1],sizeof(double),atom->nangletypes,fp,nullptr,error);
|
||||
}
|
||||
MPI_Bcast(&theta0[1],atom->nangletypes,MPI_DOUBLE,0,world);
|
||||
|
||||
for (int i = 1; i <= atom->nangletypes; i++) setflag[i] = 1;
|
||||
}
|
||||
/* ----------------------------------------------------------------------
|
||||
proc 0 writes to data file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AngleZero2::write_data(FILE *fp)
|
||||
{
|
||||
for (int i = 1; i <= atom->nangletypes; i++)
|
||||
fprintf(fp,"%d %g\n",i,theta0[i]/MY_PI*180.0);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
double AngleZero2::single(int /*type*/, int /*i1*/, int /*i2*/, int /*i3*/)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
57
examples/plugins/angle_zero2.h
Normal file
57
examples/plugins/angle_zero2.h
Normal file
@ -0,0 +1,57 @@
|
||||
/* -*- 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef LMP_ANGLE_ZERO2_H
|
||||
#define LMP_ANGLE_ZERO2_H
|
||||
|
||||
#include "angle.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class AngleZero2 : public Angle {
|
||||
public:
|
||||
AngleZero2(class LAMMPS *);
|
||||
virtual ~AngleZero2();
|
||||
virtual void compute(int, int);
|
||||
virtual void coeff(int, char **);
|
||||
virtual void settings(int, char **);
|
||||
|
||||
double equilibrium_angle(int);
|
||||
void write_restart(FILE *);
|
||||
void read_restart(FILE *);
|
||||
void write_data(FILE *);
|
||||
|
||||
double single(int, int, int, int);
|
||||
|
||||
protected:
|
||||
double *theta0;
|
||||
int coeffflag;
|
||||
|
||||
void allocate();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* ERROR/WARNING messages:
|
||||
|
||||
E: Illegal ... command
|
||||
|
||||
UNDOCUMENTED
|
||||
|
||||
E: Incorrect args for angle coefficients
|
||||
|
||||
Self-explanatory. Check the input script or data file.
|
||||
|
||||
*/
|
||||
161
examples/plugins/bond_zero2.cpp
Normal file
161
examples/plugins/bond_zero2.cpp
Normal file
@ -0,0 +1,161 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://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: Carsten Svaneborg (SDU)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "bond_zero2.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "comm.h"
|
||||
#include "error.h"
|
||||
#include "memory.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
BondZero2::BondZero2(LAMMPS *lmp) : Bond(lmp), coeffflag(1) {}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
BondZero2::~BondZero2()
|
||||
{
|
||||
if (allocated && !copymode) {
|
||||
memory->destroy(setflag);
|
||||
memory->destroy(r0);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void BondZero2::compute(int eflag, int vflag)
|
||||
{
|
||||
ev_init(eflag,vflag);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void BondZero2::settings(int narg, char **arg)
|
||||
{
|
||||
if ((narg != 0) && (narg != 1))
|
||||
error->all(FLERR,"Illegal bond_style command");
|
||||
|
||||
if (narg == 1) {
|
||||
if (strcmp("nocoeff",arg[0]) == 0) coeffflag=0;
|
||||
else error->all(FLERR,"Illegal bond_style command");
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void BondZero2::allocate()
|
||||
{
|
||||
allocated = 1;
|
||||
int n = atom->nbondtypes;
|
||||
|
||||
memory->create(r0,n+1,"bond:r0");
|
||||
memory->create(setflag,n+1,"bond:setflag");
|
||||
for (int i = 1; i <= n; i++) setflag[i] = 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
set coeffs for one or more types
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void BondZero2::coeff(int narg, char **arg)
|
||||
{
|
||||
if ((narg < 1) || (coeffflag && narg > 2))
|
||||
error->all(FLERR,"Incorrect args for bond coefficients");
|
||||
|
||||
if (!allocated) allocate();
|
||||
|
||||
int ilo,ihi;
|
||||
utils::bounds(FLERR,arg[0],1,atom->nbondtypes,ilo,ihi,error);
|
||||
|
||||
double r0_one = 0.0;
|
||||
if (coeffflag && (narg == 2))
|
||||
r0_one = utils::numeric(FLERR,arg[1],false,lmp);
|
||||
|
||||
int count = 0;
|
||||
for (int i = ilo; i <= ihi; i++) {
|
||||
setflag[i] = 1;
|
||||
r0[i] = r0_one;
|
||||
count++;
|
||||
}
|
||||
|
||||
if (count == 0) error->all(FLERR,"Incorrect args for bond coefficients");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
return an equilbrium bond length
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double BondZero2::equilibrium_distance(int i)
|
||||
{
|
||||
return r0[i];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
proc 0 writes out coeffs to restart file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void BondZero2::write_restart(FILE *fp) {
|
||||
fwrite(&r0[1],sizeof(double),atom->nbondtypes,fp);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
proc 0 reads coeffs from restart file, bcasts them
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void BondZero2::read_restart(FILE *fp)
|
||||
{
|
||||
allocate();
|
||||
|
||||
if (comm->me == 0) {
|
||||
utils::sfread(FLERR,&r0[1],sizeof(double),atom->nbondtypes,fp,nullptr,error);
|
||||
}
|
||||
MPI_Bcast(&r0[1],atom->nbondtypes,MPI_DOUBLE,0,world);
|
||||
|
||||
for (int i = 1; i <= atom->nbondtypes; i++) setflag[i] = 1;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
proc 0 writes to data file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void BondZero2::write_data(FILE *fp)
|
||||
{
|
||||
for (int i = 1; i <= atom->nbondtypes; i++)
|
||||
fprintf(fp,"%d %g\n",i,r0[i]);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
double BondZero2::single(int /*type*/, double /*rsq*/, int /*i*/, int /*j*/,
|
||||
double & /*fforce*/)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void *BondZero2::extract(const char *str, int &dim)
|
||||
{
|
||||
dim = 1;
|
||||
if (strcmp(str,"r0")==0) return (void*) r0;
|
||||
return nullptr;
|
||||
}
|
||||
58
examples/plugins/bond_zero2.h
Normal file
58
examples/plugins/bond_zero2.h
Normal file
@ -0,0 +1,58 @@
|
||||
/* -*- 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef LMP_BOND_ZERO2_H
|
||||
#define LMP_BOND_ZERO2_H
|
||||
|
||||
#include "bond.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class BondZero2 : public Bond {
|
||||
public:
|
||||
BondZero2(class LAMMPS *);
|
||||
virtual ~BondZero2();
|
||||
virtual void compute(int, int);
|
||||
virtual void settings(int, char **);
|
||||
|
||||
void coeff(int, char **);
|
||||
double equilibrium_distance(int);
|
||||
void write_restart(FILE *);
|
||||
void read_restart(FILE *);
|
||||
void write_data(FILE *);
|
||||
|
||||
double single(int, double, int, int, double &);
|
||||
virtual void *extract(const char *, int &);
|
||||
|
||||
protected:
|
||||
double *r0;
|
||||
int coeffflag;
|
||||
|
||||
virtual void allocate();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* ERROR/WARNING messages:
|
||||
|
||||
E: Illegal ... command
|
||||
|
||||
UNDOCUMENTED
|
||||
|
||||
E: Incorrect args for bond coefficients
|
||||
|
||||
Self-explanatory. Check the input script or data file.
|
||||
|
||||
*/
|
||||
121
examples/plugins/dihedral_zero2.cpp
Normal file
121
examples/plugins/dihedral_zero2.cpp
Normal file
@ -0,0 +1,121 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://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: Carsten Svaneborg (SDU)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "dihedral_zero2.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "error.h"
|
||||
#include "memory.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
DihedralZero2::DihedralZero2(LAMMPS *lmp) : Dihedral(lmp), coeffflag(1)
|
||||
{
|
||||
writedata = 1;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
DihedralZero2::~DihedralZero2()
|
||||
{
|
||||
if (allocated && !copymode) {
|
||||
memory->destroy(setflag);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void DihedralZero2::compute(int eflag, int vflag)
|
||||
{
|
||||
ev_init(eflag,vflag);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void DihedralZero2::settings(int narg, char **arg)
|
||||
{
|
||||
if ((narg != 0) && (narg != 1))
|
||||
error->all(FLERR,"Illegal dihedral_style command");
|
||||
|
||||
if (narg == 1) {
|
||||
if (strcmp("nocoeff",arg[0]) == 0) coeffflag=0;
|
||||
else error->all(FLERR,"Illegal dihedral_style command");
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void DihedralZero2::allocate()
|
||||
{
|
||||
allocated = 1;
|
||||
int n = atom->ndihedraltypes;
|
||||
|
||||
memory->create(setflag,n+1,"dihedral:setflag");
|
||||
for (int i = 1; i <= n; i++) setflag[i] = 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
set coeffs for one or more types
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void DihedralZero2::coeff(int narg, char **arg)
|
||||
{
|
||||
if ((narg < 1) || (coeffflag && narg > 1))
|
||||
error->all(FLERR,"Incorrect args for dihedral coefficients");
|
||||
|
||||
if (!allocated) allocate();
|
||||
|
||||
int ilo,ihi;
|
||||
utils::bounds(FLERR,arg[0],1,atom->ndihedraltypes,ilo,ihi,error);
|
||||
|
||||
int count = 0;
|
||||
for (int i = ilo; i <= ihi; i++) {
|
||||
setflag[i] = 1;
|
||||
count++;
|
||||
}
|
||||
|
||||
if (count == 0) error->all(FLERR,"Incorrect args for dihedral coefficients");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
proc 0 writes out coeffs to restart file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void DihedralZero2::write_restart(FILE * /*fp*/) {}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
proc 0 reads coeffs from restart file, bcasts them
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void DihedralZero2::read_restart(FILE * /*fp*/)
|
||||
{
|
||||
allocate();
|
||||
for (int i = 1; i <= atom->ndihedraltypes; i++) setflag[i] = 1;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
proc 0 writes to data file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void DihedralZero2::write_data(FILE *fp) {
|
||||
for (int i = 1; i <= atom->ndihedraltypes; i++)
|
||||
fprintf(fp,"%d\n",i);
|
||||
}
|
||||
57
examples/plugins/dihedral_zero2.h
Normal file
57
examples/plugins/dihedral_zero2.h
Normal file
@ -0,0 +1,57 @@
|
||||
/* -*- 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.
|
||||
|
||||
Identical to dihedral harmonic, except if all k's are zero the
|
||||
force loop is skipped.
|
||||
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef LMP_DIHEDRAL_ZERO2_H
|
||||
#define LMP_DIHEDRAL_ZERO2_H
|
||||
|
||||
#include "dihedral.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class DihedralZero2 : public Dihedral {
|
||||
public:
|
||||
DihedralZero2(class LAMMPS *);
|
||||
virtual ~DihedralZero2();
|
||||
virtual void compute(int, int);
|
||||
virtual void coeff(int, char **);
|
||||
virtual void settings(int, char **);
|
||||
|
||||
void write_restart(FILE *);
|
||||
void read_restart(FILE *);
|
||||
void write_data(FILE *);
|
||||
|
||||
protected:
|
||||
int coeffflag;
|
||||
|
||||
virtual void allocate();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* ERROR/WARNING messages:
|
||||
|
||||
E: Illegal ... command
|
||||
|
||||
UNDOCUMENTED
|
||||
|
||||
E: Incorrect args for dihedral coefficients
|
||||
|
||||
UNDOCUMENTED
|
||||
|
||||
*/
|
||||
122
examples/plugins/improper_zero2.cpp
Normal file
122
examples/plugins/improper_zero2.cpp
Normal file
@ -0,0 +1,122 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://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: Carsten Svaneborg (SDU)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "improper_zero2.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "error.h"
|
||||
#include "memory.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ImproperZero2::ImproperZero2(LAMMPS *lmp) : Improper(lmp), coeffflag(1)
|
||||
{
|
||||
writedata = 1;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ImproperZero2::~ImproperZero2()
|
||||
{
|
||||
if (allocated && !copymode) {
|
||||
memory->destroy(setflag);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ImproperZero2::compute(int eflag, int vflag)
|
||||
{
|
||||
ev_init(eflag,vflag);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ImproperZero2::settings(int narg, char **arg)
|
||||
{
|
||||
if ((narg != 0) && (narg != 1))
|
||||
error->all(FLERR,"Illegal improper_style command");
|
||||
|
||||
if (narg == 1) {
|
||||
if (strcmp("nocoeff",arg[0]) == 0) coeffflag=0;
|
||||
else error->all(FLERR,"Illegal improper_style command");
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ImproperZero2::allocate()
|
||||
{
|
||||
allocated = 1;
|
||||
int n = atom->nimpropertypes;
|
||||
|
||||
memory->create(setflag,n+1,"improper:setflag");
|
||||
for (int i = 1; i <= n; i++) setflag[i] = 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
set coeffs for one or more types
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ImproperZero2::coeff(int narg, char **arg)
|
||||
{
|
||||
if ((narg < 1) || (coeffflag && narg > 1))
|
||||
error->all(FLERR,"Incorrect args for improper coefficients");
|
||||
|
||||
if (!allocated) allocate();
|
||||
|
||||
int ilo,ihi;
|
||||
utils::bounds(FLERR,arg[0],1,atom->nimpropertypes,ilo,ihi,error);
|
||||
|
||||
int count = 0;
|
||||
for (int i = ilo; i <= ihi; i++) {
|
||||
setflag[i] = 1;
|
||||
count++;
|
||||
}
|
||||
|
||||
if (count == 0) error->all(FLERR,"Incorrect args for improper coefficients");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
proc 0 writes out coeffs to restart file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ImproperZero2::write_restart(FILE * /*fp*/) {}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
proc 0 reads coeffs from restart file, bcasts them
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ImproperZero2::read_restart(FILE * /*fp*/)
|
||||
{
|
||||
allocate();
|
||||
for (int i = 1; i <= atom->nimpropertypes; i++) setflag[i] = 1;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
proc 0 writes to data file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ImproperZero2::write_data(FILE *fp) {
|
||||
for (int i = 1; i <= atom->nimpropertypes; i++)
|
||||
fprintf(fp,"%d\n",i);
|
||||
}
|
||||
|
||||
53
examples/plugins/improper_zero2.h
Normal file
53
examples/plugins/improper_zero2.h
Normal file
@ -0,0 +1,53 @@
|
||||
/* -*- 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef LMP_IMPROPER_ZERO2_H
|
||||
#define LMP_IMPROPER_ZERO2_H
|
||||
|
||||
#include "improper.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class ImproperZero2 : public Improper {
|
||||
public:
|
||||
ImproperZero2(class LAMMPS *);
|
||||
virtual ~ImproperZero2();
|
||||
virtual void compute(int, int);
|
||||
virtual void coeff(int, char **);
|
||||
virtual void settings(int, char **);
|
||||
|
||||
void write_restart(FILE *);
|
||||
void read_restart(FILE *);
|
||||
void write_data(FILE *);
|
||||
|
||||
protected:
|
||||
int coeffflag;
|
||||
|
||||
virtual void allocate();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* ERROR/WARNING messages:
|
||||
|
||||
E: Illegal ... command
|
||||
|
||||
UNDOCUMENTED
|
||||
|
||||
E: Incorrect args for improper coefficients
|
||||
|
||||
Self-explanatory. Check the input script or data file.
|
||||
|
||||
*/
|
||||
247
examples/plugins/pair_zero2.cpp
Normal file
247
examples/plugins/pair_zero2.cpp
Normal file
@ -0,0 +1,247 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://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: Carsten Svaneborg (SDU)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "pair_zero2.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "comm.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PairZero2::PairZero2(LAMMPS *lmp) : Pair(lmp) {
|
||||
coeffflag=1;
|
||||
writedata=1;
|
||||
single_enable=1;
|
||||
respa_enable=1;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PairZero2::~PairZero2()
|
||||
{
|
||||
if (allocated) {
|
||||
memory->destroy(setflag);
|
||||
memory->destroy(cutsq);
|
||||
memory->destroy(cut);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void PairZero2::compute(int eflag, int vflag)
|
||||
{
|
||||
ev_init(eflag,vflag);
|
||||
if (vflag_fdotr) virial_fdotr_compute();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void PairZero2::compute_outer(int eflag, int vflag)
|
||||
{
|
||||
ev_init(eflag,vflag);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
allocate all arrays
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void PairZero2::allocate()
|
||||
{
|
||||
allocated = 1;
|
||||
int n = atom->ntypes;
|
||||
|
||||
memory->create(setflag,n+1,n+1,"pair:setflag");
|
||||
for (int i = 1; i <= n; i++)
|
||||
for (int j = i; j <= n; j++)
|
||||
setflag[i][j] = 0;
|
||||
|
||||
memory->create(cutsq,n+1,n+1,"pair:cutsq");
|
||||
memory->create(cut,n+1,n+1,"pair:cut");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
global settings
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void PairZero2::settings(int narg, char **arg)
|
||||
{
|
||||
if ((narg != 1) && (narg != 2))
|
||||
error->all(FLERR,"Illegal pair_style command");
|
||||
|
||||
cut_global = utils::numeric(FLERR,arg[0],false,lmp);
|
||||
if (narg == 2) {
|
||||
if (strcmp("nocoeff",arg[1]) == 0) coeffflag=0;
|
||||
else error->all(FLERR,"Illegal pair_style command");
|
||||
}
|
||||
|
||||
// reset cutoffs that have been explicitly set
|
||||
|
||||
if (allocated) {
|
||||
int i,j;
|
||||
for (i = 1; i <= atom->ntypes; i++)
|
||||
for (j = i+1; j <= atom->ntypes; j++)
|
||||
cut[i][j] = cut_global;
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
set coeffs for one or more type pairs
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void PairZero2::coeff(int narg, char **arg)
|
||||
{
|
||||
if ((narg < 2) || (coeffflag && narg > 3))
|
||||
error->all(FLERR,"Incorrect args for pair coefficients");
|
||||
|
||||
if (!allocated) allocate();
|
||||
|
||||
int ilo,ihi,jlo,jhi;
|
||||
utils::bounds(FLERR,arg[0],1,atom->ntypes,ilo,ihi,error);
|
||||
utils::bounds(FLERR,arg[1],1,atom->ntypes,jlo,jhi,error);
|
||||
|
||||
double cut_one = cut_global;
|
||||
if (coeffflag && (narg == 3)) cut_one = utils::numeric(FLERR,arg[2],false,lmp);
|
||||
|
||||
int count = 0;
|
||||
for (int i = ilo; i <= ihi; i++) {
|
||||
for (int j = MAX(jlo,i); j <= jhi; j++) {
|
||||
cut[i][j] = cut_one;
|
||||
setflag[i][j] = 1;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
init for one type pair i,j and corresponding j,i
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double PairZero2::init_one(int i, int j)
|
||||
{
|
||||
if (setflag[i][j] == 0) {
|
||||
cut[i][j] = mix_distance(cut[i][i],cut[j][j]);
|
||||
}
|
||||
|
||||
return cut[i][j];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
proc 0 writes to restart file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void PairZero2::write_restart(FILE *fp)
|
||||
{
|
||||
write_restart_settings(fp);
|
||||
|
||||
int i,j;
|
||||
for (i = 1; i <= atom->ntypes; i++)
|
||||
for (j = i; j <= atom->ntypes; j++) {
|
||||
fwrite(&setflag[i][j],sizeof(int),1,fp);
|
||||
if (setflag[i][j]) {
|
||||
fwrite(&cut[i][j],sizeof(double),1,fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
proc 0 reads from restart file, bcasts
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void PairZero2::read_restart(FILE *fp)
|
||||
{
|
||||
read_restart_settings(fp);
|
||||
allocate();
|
||||
|
||||
int i,j;
|
||||
int me = comm->me;
|
||||
for (i = 1; i <= atom->ntypes; i++)
|
||||
for (j = i; j <= atom->ntypes; j++) {
|
||||
if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,nullptr,error);
|
||||
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
|
||||
if (setflag[i][j]) {
|
||||
if (me == 0) {
|
||||
utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,nullptr,error);
|
||||
}
|
||||
MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
proc 0 writes to restart file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void PairZero2::write_restart_settings(FILE *fp)
|
||||
{
|
||||
fwrite(&cut_global,sizeof(double),1,fp);
|
||||
fwrite(&coeffflag,sizeof(int),1,fp);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
proc 0 reads from restart file, bcasts
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void PairZero2::read_restart_settings(FILE *fp)
|
||||
{
|
||||
int me = comm->me;
|
||||
if (me == 0) {
|
||||
utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,nullptr,error);
|
||||
utils::sfread(FLERR,&coeffflag,sizeof(int),1,fp,nullptr,error);
|
||||
}
|
||||
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&coeffflag,1,MPI_INT,0,world);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
proc 0 writes to data file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void PairZero2::write_data(FILE *fp)
|
||||
{
|
||||
for (int i = 1; i <= atom->ntypes; i++)
|
||||
fprintf(fp,"%d\n",i);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
proc 0 writes all pairs to data file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void PairZero2::write_data_all(FILE *fp)
|
||||
{
|
||||
for (int i = 1; i <= atom->ntypes; i++)
|
||||
for (int j = i; j <= atom->ntypes; j++)
|
||||
fprintf(fp,"%d %d %g\n",i,j,cut[i][j]);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
double PairZero2::single(int /*i*/, int /*j*/, int /* itype */, int /* jtype */,
|
||||
double /* rsq */, double /*factor_coul*/,
|
||||
double /* factor_lj */, double &fforce)
|
||||
{
|
||||
fforce = 0.0;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
77
examples/plugins/pair_zero2.h
Normal file
77
examples/plugins/pair_zero2.h
Normal file
@ -0,0 +1,77 @@
|
||||
/* -*- 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.
|
||||
|
||||
Pair zero is a dummy pair interaction useful for requiring a
|
||||
force cutoff distance in the absence of pair-interactions or
|
||||
with hybrid/overlay if a larger force cutoff distance is required.
|
||||
|
||||
This can be used in conjunction with bond/create to create bonds
|
||||
that are longer than the cutoff of a given force field, or to
|
||||
calculate radial distribution functions for models without
|
||||
pair interactions.
|
||||
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef LMP_PAIR_ZERO2_H
|
||||
#define LMP_PAIR_ZERO2_H
|
||||
|
||||
#include "pair.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class PairZero2 : public Pair {
|
||||
public:
|
||||
PairZero2(class LAMMPS *);
|
||||
virtual ~PairZero2();
|
||||
virtual void compute(int, int);
|
||||
virtual void compute_outer(int, int);
|
||||
void settings(int, char **);
|
||||
void coeff(int, char **);
|
||||
double init_one(int, int);
|
||||
void write_restart(FILE *);
|
||||
void read_restart(FILE *);
|
||||
void write_restart_settings(FILE *);
|
||||
void read_restart_settings(FILE *);
|
||||
void write_data(FILE *);
|
||||
void write_data_all(FILE *);
|
||||
double single(int, int, int, int, double, double, double, double &);
|
||||
|
||||
protected:
|
||||
double cut_global;
|
||||
double **cut;
|
||||
int coeffflag;
|
||||
|
||||
virtual void allocate();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* ERROR/WARNING messages:
|
||||
|
||||
E: Illegal ... command
|
||||
|
||||
Self-explanatory. Check the input script syntax and compare to the
|
||||
documentation for the command. You can use -echo screen as a
|
||||
command-line option when running LAMMPS to see the offending line.
|
||||
|
||||
E: Incorrect args for pair coefficients
|
||||
|
||||
Self-explanatory. Check the input script or data file.
|
||||
|
||||
U: Pair cutoff < Respa interior cutoff
|
||||
|
||||
One or more pairwise cutoffs are too short to use with the specified
|
||||
rRESPA cutoffs.
|
||||
|
||||
*/
|
||||
78
examples/plugins/zero2plugin.cpp
Normal file
78
examples/plugins/zero2plugin.cpp
Normal file
@ -0,0 +1,78 @@
|
||||
|
||||
#include "lammpsplugin.h"
|
||||
#include "version.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "pair_zero2.h"
|
||||
#include "bond_zero2.h"
|
||||
#include "angle_zero2.h"
|
||||
#include "dihedral_zero2.h"
|
||||
#include "improper_zero2.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
static Pair *pairzerocreator(LAMMPS *lmp)
|
||||
{
|
||||
return new PairZero2(lmp);
|
||||
}
|
||||
|
||||
static Bond *bondzerocreator(LAMMPS *lmp)
|
||||
{
|
||||
return new BondZero2(lmp);
|
||||
}
|
||||
|
||||
static Angle *anglezerocreator(LAMMPS *lmp)
|
||||
{
|
||||
return new AngleZero2(lmp);
|
||||
}
|
||||
|
||||
static Dihedral *dihedralzerocreator(LAMMPS *lmp)
|
||||
{
|
||||
return new DihedralZero2(lmp);
|
||||
}
|
||||
|
||||
static Improper *improperzerocreator(LAMMPS *lmp)
|
||||
{
|
||||
return new ImproperZero2(lmp);
|
||||
}
|
||||
|
||||
extern "C" void lammpsplugin_init(void *lmp, void *handle, void *regfunc)
|
||||
{
|
||||
lammpsplugin_t plugin;
|
||||
lammpsplugin_regfunc register_plugin = (lammpsplugin_regfunc) regfunc;
|
||||
|
||||
// register zero2 pair style
|
||||
plugin.version = LAMMPS_VERSION;
|
||||
plugin.style = "pair";
|
||||
plugin.name = "zero2";
|
||||
plugin.info = "Zero2 variant pair style v1.0";
|
||||
plugin.author = "Axel Kohlmeyer (akohlmey@gmail.com)";
|
||||
plugin.creator.v1 = (lammpsplugin_factory1 *) &pairzerocreator;
|
||||
plugin.handle = handle;
|
||||
(*register_plugin)(&plugin,lmp);
|
||||
|
||||
// register zero2 bond style
|
||||
plugin.style = "bond";
|
||||
plugin.info = "Zero2 variant bond style v1.0";
|
||||
plugin.creator.v1 = (lammpsplugin_factory1 *) &bondzerocreator;
|
||||
(*register_plugin)(&plugin,lmp);
|
||||
|
||||
// register zero2 angle style
|
||||
plugin.style = "angle";
|
||||
plugin.info = "Zero2 variant angle style v1.0";
|
||||
plugin.creator.v1 = (lammpsplugin_factory1 *) &anglezerocreator;
|
||||
(*register_plugin)(&plugin,lmp);
|
||||
|
||||
// register zero2 dihedral style
|
||||
plugin.style = "dihedral";
|
||||
plugin.info = "Zero2 variant dihedral style v1.0";
|
||||
plugin.creator.v1 = (lammpsplugin_factory1 *) &dihedralzerocreator;
|
||||
(*register_plugin)(&plugin,lmp);
|
||||
|
||||
// register zero2 improper style
|
||||
plugin.style = "improper";
|
||||
plugin.info = "Zero2 variant improper style v1.0";
|
||||
plugin.creator.v1 = (lammpsplugin_factory1 *) &improperzerocreator;
|
||||
(*register_plugin)(&plugin,lmp);
|
||||
}
|
||||
@ -19,7 +19,6 @@
|
||||
#include "force.h"
|
||||
#include "lammps.h"
|
||||
#include "modify.h"
|
||||
#include "pair.h"
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
@ -179,6 +178,46 @@ namespace LAMMPS_NS
|
||||
}
|
||||
(*pair_map)[plugin->name] = (Force::PairCreator)plugin->creator.v1;
|
||||
|
||||
} else if (pstyle == "bond") {
|
||||
auto bond_map = lmp->force->bond_map;
|
||||
if (bond_map->find(plugin->name) != bond_map->end()) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,fmt::format("Overriding built-in bond "
|
||||
"style {} from plugin",
|
||||
plugin->name));
|
||||
}
|
||||
(*bond_map)[plugin->name] = (Force::BondCreator)plugin->creator.v1;
|
||||
|
||||
} else if (pstyle == "angle") {
|
||||
auto angle_map = lmp->force->angle_map;
|
||||
if (angle_map->find(plugin->name) != angle_map->end()) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,fmt::format("Overriding built-in angle "
|
||||
"style {} from plugin",
|
||||
plugin->name));
|
||||
}
|
||||
(*angle_map)[plugin->name] = (Force::AngleCreator)plugin->creator.v1;
|
||||
|
||||
} else if (pstyle == "dihedral") {
|
||||
auto dihedral_map = lmp->force->dihedral_map;
|
||||
if (dihedral_map->find(plugin->name) != dihedral_map->end()) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,fmt::format("Overriding built-in dihedral "
|
||||
"style {} from plugin",
|
||||
plugin->name));
|
||||
}
|
||||
(*dihedral_map)[plugin->name] = (Force::DihedralCreator)plugin->creator.v1;
|
||||
|
||||
} else if (pstyle == "improper") {
|
||||
auto improper_map = lmp->force->improper_map;
|
||||
if (improper_map->find(plugin->name) != improper_map->end()) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,fmt::format("Overriding built-in improper "
|
||||
"style {} from plugin",
|
||||
plugin->name));
|
||||
}
|
||||
(*improper_map)[plugin->name] = (Force::ImproperCreator)plugin->creator.v1;
|
||||
|
||||
} else if (pstyle == "fix") {
|
||||
auto fix_map = lmp->modify->fix_map;
|
||||
if (fix_map->find(plugin->name) != fix_map->end()) {
|
||||
@ -219,8 +258,9 @@ namespace LAMMPS_NS
|
||||
int me = lmp->comm->me;
|
||||
|
||||
// ignore unload request from unsupported style categories
|
||||
if ((strcmp(style,"pair") != 0)
|
||||
&& (strcmp(style,"fix") != 0)
|
||||
if ((strcmp(style,"pair") != 0) && (strcmp(style,"bond") != 0)
|
||||
&& (strcmp(style,"angle") != 0) && (strcmp(style,"dihedral") != 0)
|
||||
&& (strcmp(style,"improper") != 0) && (strcmp(style,"fix") != 0)
|
||||
&& (strcmp(style,"command") != 0)) {
|
||||
if (me == 0)
|
||||
utils::logmesg(lmp,fmt::format("Ignoring unload: {} is not a "
|
||||
@ -269,6 +309,54 @@ namespace LAMMPS_NS
|
||||
}
|
||||
}
|
||||
|
||||
} else if (pstyle == "bond") {
|
||||
|
||||
auto found = lmp->force->bond_map->find(name);
|
||||
if (found != lmp->force->bond_map->end())
|
||||
lmp->force->bond_map->erase(found);
|
||||
|
||||
// must delete bond style instance if in use
|
||||
|
||||
if ((lmp->force->bond_style != nullptr)
|
||||
&& (lmp->force->bond_match(name) != nullptr))
|
||||
lmp->force->create_bond("none",0);
|
||||
|
||||
} else if (pstyle == "angle") {
|
||||
|
||||
auto found = lmp->force->angle_map->find(name);
|
||||
if (found != lmp->force->angle_map->end())
|
||||
lmp->force->angle_map->erase(found);
|
||||
|
||||
// must delete angle style instance if in use
|
||||
|
||||
if ((lmp->force->angle_style != nullptr)
|
||||
&& (lmp->force->angle_match(name) != nullptr))
|
||||
lmp->force->create_angle("none",0);
|
||||
|
||||
} else if (pstyle == "dihedral") {
|
||||
|
||||
auto found = lmp->force->dihedral_map->find(name);
|
||||
if (found != lmp->force->dihedral_map->end())
|
||||
lmp->force->dihedral_map->erase(found);
|
||||
|
||||
// must delete dihedral style instance if in use
|
||||
|
||||
if ((lmp->force->dihedral_style)
|
||||
&& (lmp->force->dihedral_match(name) != nullptr))
|
||||
lmp->force->create_dihedral("none",0);
|
||||
|
||||
} else if (pstyle == "improper") {
|
||||
|
||||
auto found = lmp->force->improper_map->find(name);
|
||||
if (found != lmp->force->improper_map->end())
|
||||
lmp->force->improper_map->erase(found);
|
||||
|
||||
// must delete improper style instance if in use
|
||||
|
||||
if ((lmp->force->improper_style != nullptr)
|
||||
&& (lmp->force->improper_match(name) != nullptr))
|
||||
lmp->force->create_improper("none",0);
|
||||
|
||||
} else if (pstyle == "fix") {
|
||||
|
||||
auto fix_map = lmp->modify->fix_map;
|
||||
|
||||
Reference in New Issue
Block a user