2006-09-28 03:51:33 +08:00
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
2007-01-30 08:22:05 +08:00
|
|
|
http://lammps.sandia.gov, Sandia National Laboratories
|
|
|
|
Steve Plimpton, sjplimp@sandia.gov
|
2006-09-28 03:51:33 +08:00
|
|
|
|
|
|
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
|
|
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
2012-06-07 06:47:51 +08:00
|
|
|
certain rights in this software. This software is distributed under
|
2006-09-28 03:51:33 +08:00
|
|
|
the GNU General Public License.
|
|
|
|
|
|
|
|
See the README file in the top-level LAMMPS directory.
|
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
2015-10-31 04:04:06 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2006-09-28 03:51:33 +08:00
|
|
|
#include "create_box.h"
|
|
|
|
#include "atom.h"
|
2013-12-17 23:30:08 +08:00
|
|
|
#include "atom_vec.h"
|
2006-09-28 03:51:33 +08:00
|
|
|
#include "force.h"
|
|
|
|
#include "domain.h"
|
|
|
|
#include "region.h"
|
2007-03-08 08:54:02 +08:00
|
|
|
#include "region_prism.h"
|
2013-12-17 23:30:08 +08:00
|
|
|
#include "force.h"
|
2006-09-28 03:51:33 +08:00
|
|
|
#include "comm.h"
|
|
|
|
#include "update.h"
|
|
|
|
#include "error.h"
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
using namespace LAMMPS_NS;
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
CreateBox::CreateBox(LAMMPS *lmp) : Pointers(lmp) {}
|
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void CreateBox::command(int narg, char **arg)
|
|
|
|
{
|
2013-12-17 23:30:08 +08:00
|
|
|
if (narg < 2) error->all(FLERR,"Illegal create_box command");
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2012-06-07 06:47:51 +08:00
|
|
|
if (domain->box_exist)
|
2011-09-24 02:06:55 +08:00
|
|
|
error->all(FLERR,"Cannot create_box after simulation box is defined");
|
2007-06-23 00:59:17 +08:00
|
|
|
if (domain->dimension == 2 && domain->zperiodic == 0)
|
2011-09-24 02:06:55 +08:00
|
|
|
error->all(FLERR,"Cannot run 2d simulation with nonperiodic Z dimension");
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2007-03-08 08:54:02 +08:00
|
|
|
domain->box_exist = 1;
|
|
|
|
|
2007-06-20 21:17:59 +08:00
|
|
|
// region check
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2007-06-20 21:17:59 +08:00
|
|
|
int iregion = domain->find_region(arg[1]);
|
2011-09-24 02:06:55 +08:00
|
|
|
if (iregion == -1) error->all(FLERR,"Create_box region ID does not exist");
|
2010-01-09 06:54:13 +08:00
|
|
|
if (domain->regions[iregion]->bboxflag == 0)
|
2011-09-24 02:06:55 +08:00
|
|
|
error->all(FLERR,"Create_box region does not support a bounding box");
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2013-08-02 22:50:14 +08:00
|
|
|
domain->regions[iregion]->init();
|
|
|
|
|
2007-03-08 08:54:02 +08:00
|
|
|
// if region not prism:
|
|
|
|
// setup orthogonal domain
|
|
|
|
// set simulation domain from region extent
|
|
|
|
// if region is prism:
|
|
|
|
// seutp triclinic domain
|
|
|
|
// set simulation domain params from prism params
|
|
|
|
|
|
|
|
if (strcmp(domain->regions[iregion]->style,"prism") != 0) {
|
2007-06-28 04:46:49 +08:00
|
|
|
domain->triclinic = 0;
|
2007-03-16 07:38:38 +08:00
|
|
|
domain->boxlo[0] = domain->regions[iregion]->extent_xlo;
|
|
|
|
domain->boxhi[0] = domain->regions[iregion]->extent_xhi;
|
|
|
|
domain->boxlo[1] = domain->regions[iregion]->extent_ylo;
|
|
|
|
domain->boxhi[1] = domain->regions[iregion]->extent_yhi;
|
|
|
|
domain->boxlo[2] = domain->regions[iregion]->extent_zlo;
|
|
|
|
domain->boxhi[2] = domain->regions[iregion]->extent_zhi;
|
2007-03-08 08:54:02 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
domain->triclinic = 1;
|
|
|
|
RegPrism *region = (RegPrism *) domain->regions[iregion];
|
2007-03-16 07:38:38 +08:00
|
|
|
domain->boxlo[0] = region->xlo;
|
|
|
|
domain->boxhi[0] = region->xhi;
|
|
|
|
domain->boxlo[1] = region->ylo;
|
|
|
|
domain->boxhi[1] = region->yhi;
|
|
|
|
domain->boxlo[2] = region->zlo;
|
|
|
|
domain->boxhi[2] = region->zhi;
|
2007-03-08 08:54:02 +08:00
|
|
|
domain->xy = region->xy;
|
|
|
|
domain->xz = region->xz;
|
|
|
|
domain->yz = region->yz;
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// if molecular, zero out topology info
|
|
|
|
|
|
|
|
if (atom->molecular) {
|
|
|
|
atom->bond_per_atom = 0;
|
|
|
|
atom->angle_per_atom = 0;
|
|
|
|
atom->dihedral_per_atom = 0;
|
|
|
|
atom->improper_per_atom = 0;
|
|
|
|
atom->nbonds = 0;
|
|
|
|
atom->nangles = 0;
|
|
|
|
atom->ndihedrals = 0;
|
|
|
|
atom->nimpropers = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// set atom and topology type quantities
|
|
|
|
|
2013-06-29 03:00:58 +08:00
|
|
|
atom->ntypes = force->inumeric(FLERR,arg[0]);
|
2006-09-28 03:51:33 +08:00
|
|
|
atom->nbondtypes = 0;
|
|
|
|
atom->nangletypes = 0;
|
|
|
|
atom->ndihedraltypes = 0;
|
|
|
|
atom->nimpropertypes = 0;
|
|
|
|
|
2013-12-17 23:30:08 +08:00
|
|
|
// process optional args that can overwrite default settings
|
|
|
|
|
|
|
|
int iarg = 2;
|
|
|
|
while (iarg < narg) {
|
2014-01-09 04:38:38 +08:00
|
|
|
if (strcmp(arg[iarg],"bond/types") == 0) {
|
2013-12-17 23:30:08 +08:00
|
|
|
if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command");
|
2015-10-31 04:04:06 +08:00
|
|
|
if (!atom->avec->bonds_allow)
|
2013-12-17 23:30:08 +08:00
|
|
|
error->all(FLERR,"No bonds allowed with this atom style");
|
|
|
|
atom->nbondtypes = force->inumeric(FLERR,arg[iarg+1]);
|
|
|
|
iarg += 2;
|
2014-01-09 04:38:38 +08:00
|
|
|
} else if (strcmp(arg[iarg],"angle/types") == 0) {
|
2013-12-17 23:30:08 +08:00
|
|
|
if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command");
|
2015-10-31 04:04:06 +08:00
|
|
|
if (!atom->avec->angles_allow)
|
2013-12-17 23:30:08 +08:00
|
|
|
error->all(FLERR,"No angles allowed with this atom style");
|
|
|
|
atom->nangletypes = force->inumeric(FLERR,arg[iarg+1]);
|
|
|
|
iarg += 2;
|
2014-01-09 04:38:38 +08:00
|
|
|
} else if (strcmp(arg[iarg],"dihedral/types") == 0) {
|
2013-12-17 23:30:08 +08:00
|
|
|
if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command");
|
2015-10-31 04:04:06 +08:00
|
|
|
if (!atom->avec->dihedrals_allow)
|
2013-12-17 23:30:08 +08:00
|
|
|
error->all(FLERR,"No dihedrals allowed with this atom style");
|
|
|
|
atom->ndihedraltypes = force->inumeric(FLERR,arg[iarg+1]);
|
|
|
|
iarg += 2;
|
2014-01-09 04:38:38 +08:00
|
|
|
} else if (strcmp(arg[iarg],"improper/types") == 0) {
|
2013-12-17 23:30:08 +08:00
|
|
|
if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command");
|
2015-10-31 04:04:06 +08:00
|
|
|
if (!atom->avec->impropers_allow)
|
2013-12-17 23:30:08 +08:00
|
|
|
error->all(FLERR,"No impropers allowed with this atom style");
|
|
|
|
atom->nimpropertypes = force->inumeric(FLERR,arg[iarg+1]);
|
|
|
|
iarg += 2;
|
2014-01-09 04:38:38 +08:00
|
|
|
} else if (strcmp(arg[iarg],"extra/bond/per/atom") == 0) {
|
2013-12-17 23:30:08 +08:00
|
|
|
if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command");
|
2015-10-31 04:04:06 +08:00
|
|
|
if (!atom->avec->bonds_allow)
|
2013-12-17 23:30:08 +08:00
|
|
|
error->all(FLERR,"No bonds allowed with this atom style");
|
|
|
|
atom->bond_per_atom = force->inumeric(FLERR,arg[iarg+1]);
|
|
|
|
iarg += 2;
|
2014-01-09 04:38:38 +08:00
|
|
|
} else if (strcmp(arg[iarg],"extra/angle/per/atom") == 0) {
|
2013-12-17 23:30:08 +08:00
|
|
|
if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command");
|
2015-10-31 04:04:06 +08:00
|
|
|
if (!atom->avec->angles_allow)
|
2013-12-17 23:30:08 +08:00
|
|
|
error->all(FLERR,"No angles allowed with this atom style");
|
|
|
|
atom->angle_per_atom = force->inumeric(FLERR,arg[iarg+1]);
|
|
|
|
iarg += 2;
|
2014-01-09 04:38:38 +08:00
|
|
|
} else if (strcmp(arg[iarg],"extra/dihedral/per/atom") == 0) {
|
2013-12-17 23:30:08 +08:00
|
|
|
if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command");
|
2015-10-31 04:04:06 +08:00
|
|
|
if (!atom->avec->dihedrals_allow)
|
2013-12-17 23:30:08 +08:00
|
|
|
error->all(FLERR,"No dihedrals allowed with this atom style");
|
|
|
|
atom->dihedral_per_atom = force->inumeric(FLERR,arg[iarg+1]);
|
|
|
|
iarg += 2;
|
2014-01-09 04:38:38 +08:00
|
|
|
} else if (strcmp(arg[iarg],"extra/improper/per/atom") == 0) {
|
2013-12-17 23:30:08 +08:00
|
|
|
if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command");
|
2015-10-31 04:04:06 +08:00
|
|
|
if (!atom->avec->impropers_allow)
|
2013-12-17 23:30:08 +08:00
|
|
|
error->all(FLERR,"No impropers allowed with this atom style");
|
|
|
|
atom->improper_per_atom = force->inumeric(FLERR,arg[iarg+1]);
|
|
|
|
iarg += 2;
|
2014-01-09 04:38:38 +08:00
|
|
|
} else if (strcmp(arg[iarg],"extra/special/per/atom") == 0) {
|
|
|
|
if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command");
|
2016-09-01 04:26:15 +08:00
|
|
|
force->special_extra = force->inumeric(FLERR,arg[iarg+1]);
|
2016-10-21 23:55:36 +08:00
|
|
|
atom->maxspecial += force->special_extra;
|
2014-01-09 04:38:38 +08:00
|
|
|
iarg += 2;
|
2013-12-17 23:30:08 +08:00
|
|
|
} else error->all(FLERR,"Illegal create_box command");
|
|
|
|
}
|
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
// problem setup using info from header
|
2014-05-08 00:15:31 +08:00
|
|
|
// deallocate/grow insures any extra settings are used for topology arrays
|
|
|
|
// necessary in case no create_atoms is performed
|
2006-09-28 03:51:33 +08:00
|
|
|
|
|
|
|
update->ntimestep = 0;
|
|
|
|
|
|
|
|
atom->allocate_type_arrays();
|
2014-05-08 00:15:31 +08:00
|
|
|
atom->deallocate_topology();
|
2014-05-08 02:12:12 +08:00
|
|
|
atom->avec->grow(1);
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2007-03-08 08:54:02 +08:00
|
|
|
domain->print_box("Created ");
|
2006-09-28 03:51:33 +08:00
|
|
|
domain->set_initial_box();
|
|
|
|
domain->set_global_box();
|
2011-12-08 08:32:34 +08:00
|
|
|
comm->set_proc_grid();
|
2006-09-28 03:51:33 +08:00
|
|
|
domain->set_local_box();
|
|
|
|
}
|