diff --git a/src/atom.h b/src/atom.h index 80dadd0c6c..2f4321153a 100644 --- a/src/atom.h +++ b/src/atom.h @@ -35,7 +35,8 @@ class Atom : protected Pointers { bigint nbonds,nangles,ndihedrals,nimpropers; int ntypes,nbondtypes,nangletypes,ndihedraltypes,nimpropertypes; int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom; - int extra_bond_per_atom; + int extra_bond_per_atom,extra_angle_per_atom; + int extra_dihedral_per_atom,extra_improper_per_atom; int firstgroup; // store atoms in this group first, -1 if unset int nfirst; // # of atoms in first group on this proc diff --git a/src/create_box.cpp b/src/create_box.cpp index 3645a5e255..c0ed91150d 100644 --- a/src/create_box.cpp +++ b/src/create_box.cpp @@ -15,10 +15,12 @@ #include "string.h" #include "create_box.h" #include "atom.h" +#include "atom_vec.h" #include "force.h" #include "domain.h" #include "region.h" #include "region_prism.h" +#include "force.h" #include "comm.h" #include "update.h" #include "error.h" @@ -33,7 +35,7 @@ CreateBox::CreateBox(LAMMPS *lmp) : Pointers(lmp) {} void CreateBox::command(int narg, char **arg) { - if (narg != 2) error->all(FLERR,"Illegal create_box command"); + if (narg < 2) error->all(FLERR,"Illegal create_box command"); if (domain->box_exist) error->all(FLERR,"Cannot create_box after simulation box is defined"); @@ -102,6 +104,61 @@ void CreateBox::command(int narg, char **arg) atom->ndihedraltypes = 0; atom->nimpropertypes = 0; + // process optional args that can overwrite default settings + + int iarg = 2; + while (iarg < narg) { + if (strcmp(arg[iarg],"bond types") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command"); + if (!atom->avec->bonds_allow) + error->all(FLERR,"No bonds allowed with this atom style"); + atom->nbondtypes = force->inumeric(FLERR,arg[iarg+1]); + iarg += 2; + } else if (strcmp(arg[iarg],"angle types") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command"); + if (!atom->avec->angles_allow) + error->all(FLERR,"No angles allowed with this atom style"); + atom->nangletypes = force->inumeric(FLERR,arg[iarg+1]); + iarg += 2; + } else if (strcmp(arg[iarg],"dihedral types") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command"); + if (!atom->avec->dihedrals_allow) + error->all(FLERR,"No dihedrals allowed with this atom style"); + atom->ndihedraltypes = force->inumeric(FLERR,arg[iarg+1]); + iarg += 2; + } else if (strcmp(arg[iarg],"improper types") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command"); + if (!atom->avec->impropers_allow) + error->all(FLERR,"No impropers allowed with this atom style"); + atom->nimpropertypes = force->inumeric(FLERR,arg[iarg+1]); + iarg += 2; + } else if (strcmp(arg[iarg],"extra bond per atom") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command"); + if (!atom->avec->bonds_allow) + error->all(FLERR,"No bonds allowed with this atom style"); + atom->bond_per_atom = force->inumeric(FLERR,arg[iarg+1]); + iarg += 2; + } else if (strcmp(arg[iarg],"extra angle per atom") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command"); + if (!atom->avec->angles_allow) + error->all(FLERR,"No angles allowed with this atom style"); + atom->angle_per_atom = force->inumeric(FLERR,arg[iarg+1]); + iarg += 2; + } else if (strcmp(arg[iarg],"extra dihedral per atom") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command"); + if (!atom->avec->dihedrals_allow) + error->all(FLERR,"No dihedrals allowed with this atom style"); + atom->dihedral_per_atom = force->inumeric(FLERR,arg[iarg+1]); + iarg += 2; + } else if (strcmp(arg[iarg],"extra improper per atom") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command"); + if (!atom->avec->impropers_allow) + error->all(FLERR,"No impropers allowed with this atom style"); + atom->improper_per_atom = force->inumeric(FLERR,arg[iarg+1]); + iarg += 2; + } else error->all(FLERR,"Illegal create_box command"); + } + // problem setup using info from header // no call to atom->grow since create_atoms or fixes will do it diff --git a/src/dump_movie.cpp b/src/dump_movie.cpp index 6c11f64e16..6e08b5474e 100644 --- a/src/dump_movie.cpp +++ b/src/dump_movie.cpp @@ -52,7 +52,7 @@ void DumpMovie::openfile() sprintf(moviecmd,"ffmpeg -v error -y -r %.2f -f image2pipe -c:v ppm -i - " "-r 24.0 -b:v %dk %s ", framerate, bitrate, filename); #else - error->one(FLERR,"Cannot generate movie file"); + error->one(FLERR,"Support for writing movies not included"); #endif #if defined(_WIN32) diff --git a/src/molecule.cpp b/src/molecule.cpp index 69e810845d..15b465bdb8 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -331,6 +331,10 @@ void Molecule::types(char *line) readline(line); sscanf(line,"%d %d",&tmp,&type[i]); } + + for (int i = 0; i < natoms; i++) + if (type[i] <= 0 || type[i] > atom->ntypes) + error->all(FLERR,"Invalid atom type in molecule file"); } /* ---------------------------------------------------------------------- diff --git a/src/read_data.cpp b/src/read_data.cpp index c97be2fdff..741e96557d 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -151,6 +151,9 @@ void ReadData::command(int narg, char **arg) if (compressed) pclose(fp); else fclose(fp); atom->bond_per_atom += atom->extra_bond_per_atom; + atom->angle_per_atom += atom->extra_angle_per_atom; + atom->dihedral_per_atom += atom->extra_dihedral_per_atom; + atom->improper_per_atom += atom->extra_improper_per_atom; } MPI_Bcast(&atom->bond_per_atom,1,MPI_INT,0,world); @@ -499,6 +502,12 @@ void ReadData::header(int flag) else if (strstr(line,"extra bond per atom")) sscanf(line,"%d",&atom->extra_bond_per_atom); + else if (strstr(line,"extra angle per atom")) + sscanf(line,"%d",&atom->extra_angle_per_atom); + else if (strstr(line,"extra dihedral per atom")) + sscanf(line,"%d",&atom->extra_dihedral_per_atom); + else if (strstr(line,"extra improper per atom")) + sscanf(line,"%d",&atom->extra_improper_per_atom); else if (strstr(line,"xlo xhi")) sscanf(line,"%lg %lg",&domain->boxlo[0],&domain->boxhi[0]);