diff --git a/src/angle_zero.cpp b/src/angle_zero.cpp index 50bdc88fb..9803f6437 100644 --- a/src/angle_zero.cpp +++ b/src/angle_zero.cpp @@ -1,151 +1,151 @@ /* ---------------------------------------------------------------------- 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: Carsten Svaneborg (SDU) ------------------------------------------------------------------------- */ #include #include #include #include "angle_zero.h" #include "atom.h" #include "force.h" #include "comm.h" #include "memory.h" #include "error.h" using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ AngleZero::AngleZero(LAMMPS *lmp) : Angle(lmp), check_coeffs(1) {} /* ---------------------------------------------------------------------- */ AngleZero::~AngleZero() { if (allocated && !copymode) { memory->destroy(setflag); memory->destroy(theta0); } } /* ---------------------------------------------------------------------- */ void AngleZero::compute(int eflag, int vflag) { if (eflag || vflag) ev_setup(eflag,vflag); else evflag = 0; } /* ---------------------------------------------------------------------- */ void AngleZero::settings(int narg, char **arg) { if ((narg != 0) && (narg != 1)) error->all(FLERR,"Illegal angle_style command"); if (narg == 1) { - if (strcmp("nocoeffs",arg[0]) == 0) check_coeffs=0; + if (strcmp("nocoeff",arg[0]) == 0) check_coeffs=0; else error->all(FLERR,"Illegal angle_style command"); } } /* ---------------------------------------------------------------------- */ void AngleZero::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 AngleZero::coeff(int narg, char **arg) { if ((narg < 1) || (check_coeffs && narg > 2)) error->all(FLERR,"Incorrect args for angle coefficients"); if (!allocated) allocate(); int ilo,ihi; force->bounds(arg[0],atom->nangletypes,ilo,ihi); double theta0_one = 0.0; if (check_coeffs && (narg == 2)) theta0_one = force->numeric(FLERR,arg[1]); int count = 0; for (int i = ilo; i <= ihi; i++) { setflag[i] = 1; theta0[i] = theta0_one; count++; } if (count == 0) error->all(FLERR,"Incorrect args for angle coefficients"); } /* ---------------------------------------------------------------------- */ double AngleZero::equilibrium_angle(int i) { return theta0[i]; } /* ---------------------------------------------------------------------- proc 0 writes out coeffs to restart file ------------------------------------------------------------------------- */ void AngleZero::write_restart(FILE *fp) { fwrite(&theta0[1],sizeof(double),atom->nangletypes,fp); } /* ---------------------------------------------------------------------- proc 0 reads coeffs from restart file, bcasts them ------------------------------------------------------------------------- */ void AngleZero::read_restart(FILE *fp) { allocate(); if (comm->me == 0) { fread(&theta0[1],sizeof(double),atom->nangletypes,fp); } 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 AngleZero::write_data(FILE *fp) { for (int i = 1; i <= atom->nangletypes; i++) fprintf(fp,"%d %g\n",i,theta0[i]); } /* ---------------------------------------------------------------------- */ double AngleZero::single(int type, int i1, int i2, int i3) { return 0.0; } diff --git a/src/bond_zero.cpp b/src/bond_zero.cpp index 58ed80748..aec32468e 100644 --- a/src/bond_zero.cpp +++ b/src/bond_zero.cpp @@ -1,156 +1,156 @@ /* ---------------------------------------------------------------------- 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: Carsten Svaneborg (SDU) ------------------------------------------------------------------------- */ #include #include #include #include "bond_zero.h" #include "atom.h" #include "force.h" #include "comm.h" #include "memory.h" #include "error.h" using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ BondZero::BondZero(LAMMPS *lmp) : Bond(lmp), check_coeffs(1) {} /* ---------------------------------------------------------------------- */ BondZero::~BondZero() { if (allocated && !copymode) { memory->destroy(setflag); memory->destroy(r0); } } /* ---------------------------------------------------------------------- */ void BondZero::compute(int eflag, int vflag) { if (eflag || vflag) ev_setup(eflag,vflag); else evflag = 0; } /* ---------------------------------------------------------------------- */ void BondZero::settings(int narg, char **arg) { if ((narg != 0) && (narg != 1)) error->all(FLERR,"Illegal bond_style command"); if (narg == 1) { - if (strcmp("nocoeffs",arg[0]) == 0) check_coeffs=0; + if (strcmp("nocoeff",arg[0]) == 0) check_coeffs=0; else error->all(FLERR,"Illegal bond_style command"); } } /* ---------------------------------------------------------------------- */ void BondZero::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 BondZero::coeff(int narg, char **arg) { if ((narg < 1) || (check_coeffs && narg > 2)) error->all(FLERR,"Incorrect args for bond coefficients"); if (!allocated) allocate(); int ilo,ihi; force->bounds(arg[0],atom->nbondtypes,ilo,ihi); double r0_one = 0.0; if (check_coeffs && (narg == 2)) r0_one = force->numeric(FLERR,arg[1]); 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 BondZero::equilibrium_distance(int i) { return r0[i]; } /* ---------------------------------------------------------------------- proc 0 writes out coeffs to restart file ------------------------------------------------------------------------- */ void BondZero::write_restart(FILE *fp) { fwrite(&r0[1],sizeof(double),atom->nbondtypes,fp); } /* ---------------------------------------------------------------------- proc 0 reads coeffs from restart file, bcasts them ------------------------------------------------------------------------- */ void BondZero::read_restart(FILE *fp) { allocate(); if (comm->me == 0) { fread(&r0[1],sizeof(double),atom->nbondtypes,fp); } 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 BondZero::write_data(FILE *fp) { for (int i = 1; i <= atom->nbondtypes; i++) fprintf(fp,"%d %g\n",i,r0[i]); } /* ---------------------------------------------------------------------- */ double BondZero::single(int type, double rsq, int i, int j, double &fforce) { return 0.0; } diff --git a/src/dihedral_zero.cpp b/src/dihedral_zero.cpp index d0cea2cec..8d5ad5f02 100644 --- a/src/dihedral_zero.cpp +++ b/src/dihedral_zero.cpp @@ -1,122 +1,122 @@ /* ---------------------------------------------------------------------- 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: Carsten Svaneborg (SDU) ------------------------------------------------------------------------- */ #include #include #include #include "dihedral_zero.h" #include "atom.h" #include "force.h" #include "comm.h" #include "memory.h" #include "error.h" using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ DihedralZero::DihedralZero(LAMMPS *lmp) : Dihedral(lmp), check_coeffs(1) {} /* ---------------------------------------------------------------------- */ DihedralZero::~DihedralZero() { if (allocated && !copymode) { memory->destroy(setflag); } } /* ---------------------------------------------------------------------- */ void DihedralZero::compute(int eflag, int vflag) { if (eflag || vflag) ev_setup(eflag,vflag); else evflag = 0; } /* ---------------------------------------------------------------------- */ void DihedralZero::settings(int narg, char **arg) { if ((narg != 0) && (narg != 1)) error->all(FLERR,"Illegal dihedral_style command"); if (narg == 1) { - if (strcmp("nocoeffs",arg[0]) == 0) check_coeffs=0; + if (strcmp("nocoeff",arg[0]) == 0) check_coeffs=0; else error->all(FLERR,"Illegal dihedral_style command"); } } /* ---------------------------------------------------------------------- */ void DihedralZero::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 DihedralZero::coeff(int narg, char **arg) { if ((narg < 1) || (check_coeffs && narg > 1)) error->all(FLERR,"Incorrect args for dihedral coefficients"); if (!allocated) allocate(); int ilo,ihi; force->bounds(arg[0],atom->ndihedraltypes,ilo,ihi); 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 DihedralZero::write_restart(FILE *fp) {} /* ---------------------------------------------------------------------- proc 0 reads coeffs from restart file, bcasts them ------------------------------------------------------------------------- */ void DihedralZero::read_restart(FILE *fp) { allocate(); for (int i = 1; i <= atom->ndihedraltypes; i++) setflag[i] = 1; } /* ---------------------------------------------------------------------- proc 0 writes to data file ------------------------------------------------------------------------- */ void DihedralZero::write_data(FILE *fp) { for (int i = 1; i <= atom->ndihedraltypes; i++) fprintf(fp,"%d\n",i); } diff --git a/src/improper_zero.cpp b/src/improper_zero.cpp index ac07a87ae..a8f9923cd 100644 --- a/src/improper_zero.cpp +++ b/src/improper_zero.cpp @@ -1,122 +1,122 @@ /* ---------------------------------------------------------------------- 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: Carsten Svaneborg (SDU) ------------------------------------------------------------------------- */ #include #include #include #include "improper_zero.h" #include "atom.h" #include "force.h" #include "comm.h" #include "memory.h" #include "error.h" using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ ImproperZero::ImproperZero(LAMMPS *lmp) : Improper(lmp), check_coeffs(1) {} /* ---------------------------------------------------------------------- */ ImproperZero::~ImproperZero() { if (allocated && !copymode) { memory->destroy(setflag); } } /* ---------------------------------------------------------------------- */ void ImproperZero::compute(int eflag, int vflag) { if (eflag || vflag) ev_setup(eflag,vflag); else evflag = 0; } /* ---------------------------------------------------------------------- */ void ImproperZero::settings(int narg, char **arg) { if ((narg != 0) && (narg != 1)) error->all(FLERR,"Illegal improper_style command"); if (narg == 1) { - if (strcmp("nocoeffs",arg[0]) == 0) check_coeffs=0; + if (strcmp("nocoeff",arg[0]) == 0) check_coeffs=0; else error->all(FLERR,"Illegal improper_style command"); } } /* ---------------------------------------------------------------------- */ void ImproperZero::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 ImproperZero::coeff(int narg, char **arg) { if ((narg < 1) || (check_coeffs && narg > 1)) error->all(FLERR,"Incorrect args for improper coefficients"); if (!allocated) allocate(); int ilo,ihi; force->bounds(arg[0],atom->nimpropertypes,ilo,ihi); 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 ImproperZero::write_restart(FILE *fp) {} /* ---------------------------------------------------------------------- proc 0 reads coeffs from restart file, bcasts them ------------------------------------------------------------------------- */ void ImproperZero::read_restart(FILE *fp) { allocate(); for (int i = 1; i <= atom->nimpropertypes; i++) setflag[i] = 1; } /* ---------------------------------------------------------------------- proc 0 writes to data file ------------------------------------------------------------------------- */ void ImproperZero::write_data(FILE *fp) { for (int i = 1; i <= atom->nimpropertypes; i++) fprintf(fp,"%d\n",i); } diff --git a/src/pair_zero.cpp b/src/pair_zero.cpp index 67f4a15ae..731a743d5 100644 --- a/src/pair_zero.cpp +++ b/src/pair_zero.cpp @@ -1,205 +1,205 @@ /* ---------------------------------------------------------------------- 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: Carsten Svaneborg (SDU) ------------------------------------------------------------------------- */ #include #include #include #include #include "pair_zero.h" #include "atom.h" #include "comm.h" #include "force.h" #include "memory.h" #include "error.h" using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ PairZero::PairZero(LAMMPS *lmp) : Pair(lmp), check_coeffs(1) {} /* ---------------------------------------------------------------------- */ PairZero::~PairZero() { if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); memory->destroy(cut); } } /* ---------------------------------------------------------------------- */ void PairZero::compute(int eflag, int vflag) { if (eflag || vflag) ev_setup(eflag,vflag); else evflag = vflag_fdotr = 0; if (vflag_fdotr) virial_fdotr_compute(); } /* ---------------------------------------------------------------------- allocate all arrays ------------------------------------------------------------------------- */ void PairZero::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] = 1; memory->create(cutsq,n+1,n+1,"pair:cutsq"); memory->create(cut,n+1,n+1,"pair:cut"); } /* ---------------------------------------------------------------------- global settings ------------------------------------------------------------------------- */ void PairZero::settings(int narg, char **arg) { if ((narg != 1) && (narg != 2)) error->all(FLERR,"Illegal pair_style command"); cut_global = force->numeric(FLERR,arg[0]); if (narg == 2) { - if (strcmp("nocoeffs",arg[1]) == 0) check_coeffs=0; + if (strcmp("nocoeff",arg[1]) == 0) check_coeffs=0; else error->all(FLERR,"Illegal pair_style command"); } // reset cutoffs that have been explicitly set 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 PairZero::coeff(int narg, char **arg) { if ((narg < 2) || (check_coeffs && narg > 3)) error->all(FLERR,"Incorrect args for pair coefficients"); if (!allocated) allocate(); int ilo,ihi,jlo,jhi; force->bounds(arg[0],atom->ntypes,ilo,ihi); force->bounds(arg[1],atom->ntypes,jlo,jhi); double cut_one = cut_global; if (check_coeffs && (narg == 3)) cut_one = force->numeric(FLERR,arg[2]); int count = 0; for (int i = ilo; i <= ihi; i++) { for (int j = MAX(jlo,i); j <= jhi; j++) { cut[i][j] = cut_one; count++; } } if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); } /* ---------------------------------------------------------------------- init for one type pair i,j and corresponding j,i ------------------------------------------------------------------------- */ double PairZero::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 PairZero::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 PairZero::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) fread(&setflag[i][j],sizeof(int),1,fp); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); if (setflag[i][j]) { if (me == 0) { fread(&cut[i][j],sizeof(double),1,fp); } MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world); } } } /* ---------------------------------------------------------------------- proc 0 writes to restart file ------------------------------------------------------------------------- */ void PairZero::write_restart_settings(FILE *fp) { fwrite(&cut_global,sizeof(double),1,fp); fwrite(&check_coeffs,sizeof(int),1,fp); } /* ---------------------------------------------------------------------- proc 0 reads from restart file, bcasts ------------------------------------------------------------------------- */ void PairZero::read_restart_settings(FILE *fp) { int me = comm->me; if (me == 0) { fread(&cut_global,sizeof(double),1,fp); fread(&check_coeffs,sizeof(int),1,fp); } MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&check_coeffs,1,MPI_INT,0,world); } diff --git a/test/02_commands/in.read_data-007 b/test/02_commands/in.read_data-007 index 2848fb987..07e5c988a 100644 --- a/test/02_commands/in.read_data-007 +++ b/test/02_commands/in.read_data-007 @@ -1,27 +1,27 @@ timer off atom_style full # set up dummy styles to be able to read data file and skip force field data. -pair_style zero 5.0 nocoeffs -bond_style zero nocoeffs -angle_style zero nocoeffs -dihedral_style zero nocoeffs -improper_style zero nocoeffs +pair_style zero 5.0 nocoeff +bond_style zero nocoeff +angle_style zero nocoeff +dihedral_style zero nocoeff +improper_style zero nocoeff read_data peptide.data # apply an offset of 3 to all molecule ids variable mid atom mol+3 set group all mol v_mid info all # turn off all styles, so we get a clean data file pair_style none bond_style none angle_style none dihedral_style none improper_style none write_data new.data noinit