diff --git a/src/compute_angle.cpp b/src/compute_angle.cpp new file mode 100644 index 0000000000..9301d3ed7d --- /dev/null +++ b/src/compute_angle.cpp @@ -0,0 +1,80 @@ +/* ---------------------------------------------------------------------- + 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. +------------------------------------------------------------------------- */ + +#include +#include +#include "compute_angle.h" +#include "update.h" +#include "force.h" +#include "angle_hybrid.h" +#include "error.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +ComputeAngle::ComputeAngle(LAMMPS *lmp, int narg, char **arg) : + Compute(lmp, narg, arg) +{ + if (narg != 3) error->all(FLERR,"Illegal compute angle command"); + + vector_flag = 1; + extvector = 1; + peflag = 1; + timeflag = 1; + + // check if bond style hybrid exists + + angle = (AngleHybrid *) force->angle_match("hybrid"); + if (!angle) + error->all(FLERR,"Angle style for compute angle command is not hybrid"); + size_vector = nsub = angle->nstyles; + + emine = new double[nsub]; + vector = new double[nsub]; +} + +/* ---------------------------------------------------------------------- */ + +ComputeAngle::~ComputeAngle() +{ + delete [] emine; + delete [] vector; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeAngle::init() +{ + // recheck angle style in case it has been changed + + angle = (AngleHybrid *) force->angle_match("hybrid"); + if (!angle) + error->all(FLERR,"Angle style for compute angle command is not hybrid"); + if (angle->nstyles != nsub) + error->all(FLERR,"Angle style for compute angle command has changed"); +} + +/* ---------------------------------------------------------------------- */ + +void ComputeAngle::compute_vector() +{ + invoked_vector = update->ntimestep; + if (update->eflag_global != invoked_vector) + error->all(FLERR,"Energy was not tallied on needed timestep"); + + for (int i = 0; i < nsub; i++) + emine[i] = angle->styles[i]->energy; + + MPI_Allreduce(emine,vector,nsub,MPI_DOUBLE,MPI_SUM,world); +} diff --git a/src/compute_angle.h b/src/compute_angle.h new file mode 100644 index 0000000000..d50e3e21d7 --- /dev/null +++ b/src/compute_angle.h @@ -0,0 +1,67 @@ +/* -*- 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(angle,ComputeAngle) + +#else + +#ifndef LMP_COMPUTE_ANGLE_H +#define LMP_COMPUTE_ANGLE_H + +#include "compute.h" + +namespace LAMMPS_NS { + +class ComputeAngle : public Compute { + public: + ComputeAngle(class LAMMPS *, int, char **); + ~ComputeAngle(); + void init(); + void compute_vector(); + + private: + int nsub; + class AngleHybrid *angle; + double *emine; +}; + +} + +#endif +#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: Compute bond must use group all + +Bond styles accumlate energy on all atoms. + +E: Unrecognized bond style in compute bond command + +Self-explanatory. + +E: Energy was not tallied on needed timestep + +You are using a thermo keyword that requires potentials to +have tallied energy, but they didn't on this timestep. See the +variable doc page for ideas on how to make this work. + +*/ diff --git a/src/compute_dihedral.cpp b/src/compute_dihedral.cpp new file mode 100644 index 0000000000..c6cb97c0dd --- /dev/null +++ b/src/compute_dihedral.cpp @@ -0,0 +1,82 @@ +/* ---------------------------------------------------------------------- + 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. +------------------------------------------------------------------------- */ + +#include +#include +#include "compute_dihedral.h" +#include "update.h" +#include "force.h" +#include "dihedral_hybrid.h" +#include "error.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +ComputeDihedral::ComputeDihedral(LAMMPS *lmp, int narg, char **arg) : + Compute(lmp, narg, arg) +{ + if (narg != 3) error->all(FLERR,"Illegal compute dihedral command"); + + vector_flag = 1; + extvector = 1; + peflag = 1; + timeflag = 1; + + // check if dihedral style hybrid exists + + dihedral = (DihedralHybrid *) force->dihedral_match("hybrid"); + if (!dihedral) + error->all(FLERR, + "Dihedral style for compute dihedral command is not hybrid"); + size_vector = nsub = dihedral->nstyles; + + emine = new double[nsub]; + vector = new double[nsub]; +} + +/* ---------------------------------------------------------------------- */ + +ComputeDihedral::~ComputeDihedral() +{ + delete [] emine; + delete [] vector; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeDihedral::init() +{ + // recheck dihedral style in case it has been changed + + dihedral = (DihedralHybrid *) force->dihedral_match("hybrid"); + if (!dihedral) + error->all(FLERR, + "Dihedral style for compute dihedral command is not hybrid"); + if (dihedral->nstyles != nsub) + error->all(FLERR,"Dihedral style for compute dihedral command has changed"); +} + +/* ---------------------------------------------------------------------- */ + +void ComputeDihedral::compute_vector() +{ + invoked_vector = update->ntimestep; + if (update->eflag_global != invoked_vector) + error->all(FLERR,"Energy was not tallied on needed timestep"); + + for (int i = 0; i < nsub; i++) + emine[i] = dihedral->styles[i]->energy; + + MPI_Allreduce(emine,vector,nsub,MPI_DOUBLE,MPI_SUM,world); +} diff --git a/src/compute_dihedral.h b/src/compute_dihedral.h new file mode 100644 index 0000000000..80b78aba98 --- /dev/null +++ b/src/compute_dihedral.h @@ -0,0 +1,67 @@ +/* -*- 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(dihedral,ComputeDihedral) + +#else + +#ifndef LMP_COMPUTE_DIHEDRAL_H +#define LMP_COMPUTE_DIHEDRAL_H + +#include "compute.h" + +namespace LAMMPS_NS { + +class ComputeDihedral : public Compute { + public: + ComputeDihedral(class LAMMPS *, int, char **); + ~ComputeDihedral(); + void init(); + void compute_vector(); + + private: + int nsub; + class DihedralHybrid *dihedral; + double *emine; +}; + +} + +#endif +#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: Compute bond must use group all + +Bond styles accumlate energy on all atoms. + +E: Unrecognized bond style in compute bond command + +Self-explanatory. + +E: Energy was not tallied on needed timestep + +You are using a thermo keyword that requires potentials to +have tallied energy, but they didn't on this timestep. See the +variable doc page for ideas on how to make this work. + +*/ diff --git a/src/compute_improper.cpp b/src/compute_improper.cpp new file mode 100644 index 0000000000..961ddb2c1e --- /dev/null +++ b/src/compute_improper.cpp @@ -0,0 +1,82 @@ +/* ---------------------------------------------------------------------- + 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. +------------------------------------------------------------------------- */ + +#include +#include +#include "compute_improper.h" +#include "update.h" +#include "force.h" +#include "improper_hybrid.h" +#include "error.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +ComputeImproper::ComputeImproper(LAMMPS *lmp, int narg, char **arg) : + Compute(lmp, narg, arg) +{ + if (narg != 3) error->all(FLERR,"Illegal compute improper command"); + + vector_flag = 1; + extvector = 1; + peflag = 1; + timeflag = 1; + + // check if improper style hybrid exists + + improper = (ImproperHybrid *) force->improper_match("hybrid"); + if (!improper) + error->all(FLERR, + "Improper style for compute improper command is not hybrid"); + size_vector = nsub = improper->nstyles; + + emine = new double[nsub]; + vector = new double[nsub]; +} + +/* ---------------------------------------------------------------------- */ + +ComputeImproper::~ComputeImproper() +{ + delete [] emine; + delete [] vector; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeImproper::init() +{ + // recheck improper style in case it has been changed + + improper = (ImproperHybrid *) force->improper_match("hybrid"); + if (!improper) + error->all(FLERR, + "Improper style for compute improper command is not hybrid"); + if (improper->nstyles != nsub) + error->all(FLERR,"Improper style for compute improper command has changed"); +} + +/* ---------------------------------------------------------------------- */ + +void ComputeImproper::compute_vector() +{ + invoked_vector = update->ntimestep; + if (update->eflag_global != invoked_vector) + error->all(FLERR,"Energy was not tallied on needed timestep"); + + for (int i = 0; i < nsub; i++) + emine[i] = improper->styles[i]->energy; + + MPI_Allreduce(emine,vector,nsub,MPI_DOUBLE,MPI_SUM,world); +} diff --git a/src/compute_improper.h b/src/compute_improper.h new file mode 100644 index 0000000000..6f92f068e3 --- /dev/null +++ b/src/compute_improper.h @@ -0,0 +1,67 @@ +/* -*- 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(improper,ComputeImproper) + +#else + +#ifndef LMP_COMPUTE_IMPROPER_H +#define LMP_COMPUTE_IMPROPER_H + +#include "compute.h" + +namespace LAMMPS_NS { + +class ComputeImproper : public Compute { + public: + ComputeImproper(class LAMMPS *, int, char **); + ~ComputeImproper(); + void init(); + void compute_vector(); + + private: + int nsub; + class ImproperHybrid *improper; + double *emine; +}; + +} + +#endif +#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: Compute bond must use group all + +Bond styles accumlate energy on all atoms. + +E: Unrecognized bond style in compute bond command + +Self-explanatory. + +E: Energy was not tallied on needed timestep + +You are using a thermo keyword that requires potentials to +have tallied energy, but they didn't on this timestep. See the +variable doc page for ideas on how to make this work. + +*/ diff --git a/src/force.cpp b/src/force.cpp index 3008b81d95..f668b56b05 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -558,7 +558,7 @@ Improper *Force::improper_match(const char *style) { if (strcmp(improper_style,style) == 0) return improper; else if (strcmp(improper_style,"hybrid") == 0) { - ImproperHybrid *hybrid = (ImproperHybrid *) bond; + ImproperHybrid *hybrid = (ImproperHybrid *) improper; for (int i = 0; i < hybrid->nstyles; i++) if (strcmp(hybrid->keywords[i],style) == 0) return hybrid->styles[i]; }