2011-02-23 06:49:15 +08:00
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
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
|
2012-06-07 06:47:51 +08:00
|
|
|
certain rights in this software. This software is distributed under
|
2011-02-23 06:49:15 +08:00
|
|
|
the GNU General Public License.
|
|
|
|
|
|
|
|
See the README file in the top-level LAMMPS directory.
|
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#include "string.h"
|
|
|
|
#include "stdlib.h"
|
|
|
|
#include "update.h"
|
2011-11-12 00:52:58 +08:00
|
|
|
#include "integrate.h"
|
|
|
|
#include "min.h"
|
2011-02-23 06:49:15 +08:00
|
|
|
#include "style_integrate.h"
|
|
|
|
#include "style_minimize.h"
|
|
|
|
#include "neighbor.h"
|
2014-07-23 00:01:00 +08:00
|
|
|
#include "neigh_list.h"
|
2011-02-23 06:49:15 +08:00
|
|
|
#include "force.h"
|
|
|
|
#include "modify.h"
|
|
|
|
#include "fix.h"
|
|
|
|
#include "domain.h"
|
|
|
|
#include "region.h"
|
|
|
|
#include "compute.h"
|
|
|
|
#include "output.h"
|
|
|
|
#include "memory.h"
|
|
|
|
#include "error.h"
|
|
|
|
|
|
|
|
using namespace LAMMPS_NS;
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
Update::Update(LAMMPS *lmp) : Pointers(lmp)
|
|
|
|
{
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
ntimestep = 0;
|
2013-05-24 01:34:29 +08:00
|
|
|
atime = 0.0;
|
|
|
|
atimestep = 0;
|
2011-02-23 06:49:15 +08:00
|
|
|
first_update = 0;
|
|
|
|
|
|
|
|
whichflag = 0;
|
|
|
|
firststep = laststep = 0;
|
|
|
|
beginstep = endstep = 0;
|
|
|
|
setupflag = 0;
|
|
|
|
multireplica = 0;
|
|
|
|
|
|
|
|
restrict_output = 0;
|
|
|
|
|
|
|
|
eflag_global = vflag_global = -1;
|
|
|
|
|
|
|
|
unit_style = NULL;
|
|
|
|
set_units("lj");
|
|
|
|
|
2011-05-21 01:33:20 +08:00
|
|
|
integrate_style = NULL;
|
|
|
|
integrate = NULL;
|
|
|
|
minimize_style = NULL;
|
|
|
|
minimize = NULL;
|
|
|
|
|
2014-03-13 00:37:16 +08:00
|
|
|
str = (char *) "verlet";
|
2014-08-15 00:30:03 +08:00
|
|
|
create_integrate(1,&str,1);
|
2011-02-23 06:49:15 +08:00
|
|
|
|
|
|
|
str = (char *) "cg";
|
2011-05-21 01:33:20 +08:00
|
|
|
create_minimize(1,&str);
|
2011-02-23 06:49:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
Update::~Update()
|
|
|
|
{
|
|
|
|
delete [] unit_style;
|
|
|
|
|
|
|
|
delete [] integrate_style;
|
|
|
|
delete integrate;
|
|
|
|
|
|
|
|
delete [] minimize_style;
|
|
|
|
delete minimize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Update::init()
|
|
|
|
{
|
2011-06-07 23:25:20 +08:00
|
|
|
// if USER-CUDA mode is enabled:
|
|
|
|
// integrate/minimize style must be CUDA variant
|
|
|
|
|
|
|
|
if (whichflag == 1 && lmp->cuda)
|
|
|
|
if (strstr(integrate_style,"cuda") == NULL)
|
2011-09-24 02:06:55 +08:00
|
|
|
error->all(FLERR,"USER-CUDA mode requires CUDA variant of run style");
|
2011-06-07 23:25:20 +08:00
|
|
|
if (whichflag == 2 && lmp->cuda)
|
|
|
|
if (strstr(minimize_style,"cuda") == NULL)
|
2011-09-24 02:06:55 +08:00
|
|
|
error->all(FLERR,"USER-CUDA mode requires CUDA variant of min style");
|
2011-06-07 23:25:20 +08:00
|
|
|
|
2011-02-23 06:49:15 +08:00
|
|
|
// init the appropriate integrate and/or minimize class
|
|
|
|
// if neither (e.g. from write_restart) then just return
|
|
|
|
|
|
|
|
if (whichflag == 0) return;
|
|
|
|
if (whichflag == 1) integrate->init();
|
|
|
|
else if (whichflag == 2) minimize->init();
|
|
|
|
|
|
|
|
// only set first_update if a run or minimize is being performed
|
|
|
|
|
|
|
|
first_update = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Update::set_units(const char *style)
|
|
|
|
{
|
|
|
|
// physical constants from:
|
|
|
|
// http://physics.nist.gov/cuu/Constants/Table/allascii.txt
|
|
|
|
// using thermochemical calorie = 4.184 J
|
2012-06-07 06:47:51 +08:00
|
|
|
|
2011-02-23 06:49:15 +08:00
|
|
|
if (strcmp(style,"lj") == 0) {
|
|
|
|
force->boltz = 1.0;
|
2011-08-25 23:30:01 +08:00
|
|
|
force->hplanck = 0.18292026; // using LJ parameters for argon
|
2011-02-23 06:49:15 +08:00
|
|
|
force->mvv2e = 1.0;
|
|
|
|
force->ftm2v = 1.0;
|
|
|
|
force->mv2d = 1.0;
|
|
|
|
force->nktv2p = 1.0;
|
|
|
|
force->qqr2e = 1.0;
|
|
|
|
force->qe2f = 1.0;
|
|
|
|
force->vxmu2f = 1.0;
|
|
|
|
force->xxt2kmu = 1.0;
|
2011-06-14 05:58:07 +08:00
|
|
|
force->e_mass = 0.0; // not yet set
|
|
|
|
force->hhmrr2e = 0.0;
|
|
|
|
force->mvh2r = 0.0;
|
2012-02-25 02:32:22 +08:00
|
|
|
force->angstrom = 1.0;
|
2012-05-24 00:24:30 +08:00
|
|
|
force->femtosecond = 1.0;
|
2012-02-25 02:32:22 +08:00
|
|
|
force->qelectron = 1.0;
|
2011-06-14 05:58:07 +08:00
|
|
|
|
2011-02-23 06:49:15 +08:00
|
|
|
dt = 0.005;
|
|
|
|
neighbor->skin = 0.3;
|
2012-06-07 06:47:51 +08:00
|
|
|
|
2011-02-23 06:49:15 +08:00
|
|
|
} else if (strcmp(style,"real") == 0) {
|
|
|
|
force->boltz = 0.0019872067;
|
2011-08-25 23:30:01 +08:00
|
|
|
force->hplanck = 95.306976368;
|
2011-02-23 06:49:15 +08:00
|
|
|
force->mvv2e = 48.88821291 * 48.88821291;
|
|
|
|
force->ftm2v = 1.0 / 48.88821291 / 48.88821291;
|
2015-07-02 22:26:05 +08:00
|
|
|
force->mv2d = 1.0 / 0.602214129;
|
2011-02-23 06:49:15 +08:00
|
|
|
force->nktv2p = 68568.415;
|
|
|
|
force->qqr2e = 332.06371;
|
2012-06-07 06:47:51 +08:00
|
|
|
force->qe2f = 23.060549;
|
2011-02-23 06:49:15 +08:00
|
|
|
force->vxmu2f = 1.4393264316e4;
|
|
|
|
force->xxt2kmu = 0.1;
|
2011-06-14 05:58:07 +08:00
|
|
|
force->e_mass = 1.0/1836.1527556560675;
|
|
|
|
force->hhmrr2e = 0.0957018663603261;
|
|
|
|
force->mvh2r = 1.5339009481951;
|
2012-02-25 02:32:22 +08:00
|
|
|
force->angstrom = 1.0;
|
2012-05-24 00:24:30 +08:00
|
|
|
force->femtosecond = 1.0;
|
2012-02-25 02:32:22 +08:00
|
|
|
force->qelectron = 1.0;
|
2011-06-14 05:58:07 +08:00
|
|
|
|
2011-02-23 06:49:15 +08:00
|
|
|
dt = 1.0;
|
|
|
|
neighbor->skin = 2.0;
|
|
|
|
|
|
|
|
} else if (strcmp(style,"metal") == 0) {
|
|
|
|
force->boltz = 8.617343e-5;
|
2011-08-25 23:30:01 +08:00
|
|
|
force->hplanck = 4.135667403e-3;
|
2011-02-23 06:49:15 +08:00
|
|
|
force->mvv2e = 1.0364269e-4;
|
|
|
|
force->ftm2v = 1.0 / 1.0364269e-4;
|
2015-07-02 22:26:05 +08:00
|
|
|
force->mv2d = 1.0 / 0.602214129;
|
2011-02-23 06:49:15 +08:00
|
|
|
force->nktv2p = 1.6021765e6;
|
|
|
|
force->qqr2e = 14.399645;
|
|
|
|
force->qe2f = 1.0;
|
|
|
|
force->vxmu2f = 0.6241509647;
|
|
|
|
force->xxt2kmu = 1.0e-4;
|
2011-06-14 05:58:07 +08:00
|
|
|
force->e_mass = 0.0; // not yet set
|
|
|
|
force->hhmrr2e = 0.0;
|
|
|
|
force->mvh2r = 0.0;
|
2012-02-25 02:32:22 +08:00
|
|
|
force->angstrom = 1.0;
|
2012-05-24 00:24:30 +08:00
|
|
|
force->femtosecond = 1.0e-3;
|
2012-02-25 02:32:22 +08:00
|
|
|
force->qelectron = 1.0;
|
2011-06-14 05:58:07 +08:00
|
|
|
|
2011-02-23 06:49:15 +08:00
|
|
|
dt = 0.001;
|
|
|
|
neighbor->skin = 2.0;
|
|
|
|
|
|
|
|
} else if (strcmp(style,"si") == 0) {
|
|
|
|
force->boltz = 1.3806504e-23;
|
2011-08-25 23:30:01 +08:00
|
|
|
force->hplanck = 6.62606896e-34;
|
2011-02-23 06:49:15 +08:00
|
|
|
force->mvv2e = 1.0;
|
|
|
|
force->ftm2v = 1.0;
|
|
|
|
force->mv2d = 1.0;
|
|
|
|
force->nktv2p = 1.0;
|
|
|
|
force->qqr2e = 8.9876e9;
|
|
|
|
force->qe2f = 1.0;
|
|
|
|
force->vxmu2f = 1.0;
|
|
|
|
force->xxt2kmu = 1.0;
|
2011-06-14 05:58:07 +08:00
|
|
|
force->e_mass = 0.0; // not yet set
|
|
|
|
force->hhmrr2e = 0.0;
|
|
|
|
force->mvh2r = 0.0;
|
2012-02-28 08:19:46 +08:00
|
|
|
force->angstrom = 1.0e-10;
|
2012-05-24 00:24:30 +08:00
|
|
|
force->femtosecond = 1.0e-15;
|
2012-02-25 02:32:22 +08:00
|
|
|
force->qelectron = 1.6021765e-19;
|
2011-06-14 05:58:07 +08:00
|
|
|
|
2011-02-23 06:49:15 +08:00
|
|
|
dt = 1.0e-8;
|
|
|
|
neighbor->skin = 0.001;
|
|
|
|
|
|
|
|
} else if (strcmp(style,"cgs") == 0) {
|
|
|
|
force->boltz = 1.3806504e-16;
|
2011-08-25 23:30:01 +08:00
|
|
|
force->hplanck = 6.62606896e-27;
|
2011-02-23 06:49:15 +08:00
|
|
|
force->mvv2e = 1.0;
|
|
|
|
force->ftm2v = 1.0;
|
|
|
|
force->mv2d = 1.0;
|
|
|
|
force->nktv2p = 1.0;
|
|
|
|
force->qqr2e = 1.0;
|
|
|
|
force->qe2f = 1.0;
|
|
|
|
force->vxmu2f = 1.0;
|
|
|
|
force->xxt2kmu = 1.0;
|
2011-06-14 05:58:07 +08:00
|
|
|
force->e_mass = 0.0; // not yet set
|
|
|
|
force->hhmrr2e = 0.0;
|
|
|
|
force->mvh2r = 0.0;
|
2012-02-28 08:19:46 +08:00
|
|
|
force->angstrom = 1.0e-8;
|
2012-05-24 00:24:30 +08:00
|
|
|
force->femtosecond = 1.0e-15;
|
2012-02-25 02:32:22 +08:00
|
|
|
force->qelectron = 4.8032044e-10;
|
2011-06-14 05:58:07 +08:00
|
|
|
|
2011-02-23 06:49:15 +08:00
|
|
|
dt = 1.0e-8;
|
|
|
|
neighbor->skin = 0.1;
|
|
|
|
|
|
|
|
} else if (strcmp(style,"electron") == 0) {
|
2012-06-07 06:47:51 +08:00
|
|
|
force->boltz = 3.16681534e-6;
|
2011-08-25 23:30:01 +08:00
|
|
|
force->hplanck = 0.1519829846;
|
2012-06-07 06:47:51 +08:00
|
|
|
force->mvv2e = 1.06657236;
|
|
|
|
force->ftm2v = 0.937582899;
|
|
|
|
force->mv2d = 1.0;
|
|
|
|
force->nktv2p = 2.94210108e13;
|
|
|
|
force->qqr2e = 1.0;
|
|
|
|
force->qe2f = 1.94469051e-10;
|
|
|
|
force->vxmu2f = 3.39893149e1;
|
2011-02-23 06:49:15 +08:00
|
|
|
force->xxt2kmu = 3.13796367e-2;
|
2011-06-14 05:58:07 +08:00
|
|
|
force->e_mass = 0.0; // not yet set
|
|
|
|
force->hhmrr2e = 0.0;
|
|
|
|
force->mvh2r = 0.0;
|
2012-02-25 02:32:22 +08:00
|
|
|
force->angstrom = 1.88972612;
|
2015-01-21 07:17:36 +08:00
|
|
|
force->femtosecond = 41.34137413;
|
2012-02-25 02:32:22 +08:00
|
|
|
force->qelectron = 1.0;
|
2011-06-14 05:58:07 +08:00
|
|
|
|
2011-02-23 06:49:15 +08:00
|
|
|
dt = 0.001;
|
|
|
|
neighbor->skin = 2.0;
|
2012-06-07 06:47:51 +08:00
|
|
|
|
2013-11-08 04:30:02 +08:00
|
|
|
} else if (strcmp(style,"micro") == 0) {
|
|
|
|
force->boltz = 1.3806504e-8;
|
|
|
|
force->hplanck = 6.62606896e-13;
|
|
|
|
force->mvv2e = 1.0;
|
|
|
|
force->ftm2v = 1.0;
|
|
|
|
force->mv2d = 1.0;
|
|
|
|
force->nktv2p = 1.0;
|
2014-04-03 22:52:16 +08:00
|
|
|
force->qqr2e = 8.987556e6;
|
2013-11-08 04:30:02 +08:00
|
|
|
force->qe2f = 1.0;
|
|
|
|
force->vxmu2f = 1.0;
|
|
|
|
force->xxt2kmu = 1.0;
|
|
|
|
force->e_mass = 0.0; // not yet set
|
|
|
|
force->hhmrr2e = 0.0;
|
|
|
|
force->mvh2r = 0.0;
|
|
|
|
force->angstrom = 1.0e-4;
|
|
|
|
force->femtosecond = 1.0e-9;
|
2014-03-18 22:55:05 +08:00
|
|
|
force->qelectron = 1.6021765e-7;
|
2013-11-08 04:30:02 +08:00
|
|
|
|
|
|
|
dt = 2.0;
|
|
|
|
neighbor->skin = 0.1;
|
|
|
|
|
|
|
|
} else if (strcmp(style,"nano") == 0) {
|
2014-04-03 22:52:16 +08:00
|
|
|
force->boltz = 0.013806504;
|
2013-11-08 04:30:02 +08:00
|
|
|
force->hplanck = 6.62606896e-4;
|
|
|
|
force->mvv2e = 1.0;
|
|
|
|
force->ftm2v = 1.0;
|
|
|
|
force->mv2d = 1.0;
|
|
|
|
force->nktv2p = 1.0;
|
2014-04-03 22:52:16 +08:00
|
|
|
force->qqr2e = 230.7078669;
|
2013-11-08 04:30:02 +08:00
|
|
|
force->qe2f = 1.0;
|
|
|
|
force->vxmu2f = 1.0;
|
|
|
|
force->xxt2kmu = 1.0;
|
|
|
|
force->e_mass = 0.0; // not yet set
|
|
|
|
force->hhmrr2e = 0.0;
|
|
|
|
force->mvh2r = 0.0;
|
|
|
|
force->angstrom = 1.0e-1;
|
|
|
|
force->femtosecond = 1.0e-6;
|
2014-03-18 22:55:05 +08:00
|
|
|
force->qelectron = 1.0;
|
2013-11-08 04:30:02 +08:00
|
|
|
|
|
|
|
dt = 0.00045;
|
|
|
|
neighbor->skin = 0.1;
|
|
|
|
|
2011-09-24 02:06:55 +08:00
|
|
|
} else error->all(FLERR,"Illegal units command");
|
2011-02-23 06:49:15 +08:00
|
|
|
|
|
|
|
delete [] unit_style;
|
|
|
|
int n = strlen(style) + 1;
|
|
|
|
unit_style = new char[n];
|
|
|
|
strcpy(unit_style,style);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
2014-08-15 00:30:03 +08:00
|
|
|
void Update::create_integrate(int narg, char **arg, int trysuffix)
|
2011-02-23 06:49:15 +08:00
|
|
|
{
|
2011-09-24 02:06:55 +08:00
|
|
|
if (narg < 1) error->all(FLERR,"Illegal run_style command");
|
2011-02-23 06:49:15 +08:00
|
|
|
|
|
|
|
delete [] integrate_style;
|
|
|
|
delete integrate;
|
|
|
|
|
2011-05-21 01:33:20 +08:00
|
|
|
int sflag;
|
2014-08-15 00:30:03 +08:00
|
|
|
new_integrate(arg[0],narg-1,&arg[1],trysuffix,sflag);
|
2011-05-21 01:33:20 +08:00
|
|
|
|
|
|
|
if (sflag) {
|
|
|
|
char estyle[256];
|
2014-08-15 00:30:03 +08:00
|
|
|
if (sflag == 1) sprintf(estyle,"%s/%s",arg[0],lmp->suffix);
|
|
|
|
else sprintf(estyle,"%s/%s",arg[0],lmp->suffix2);
|
2011-05-21 01:33:20 +08:00
|
|
|
int n = strlen(estyle) + 1;
|
|
|
|
integrate_style = new char[n];
|
|
|
|
strcpy(integrate_style,estyle);
|
|
|
|
} else {
|
|
|
|
int n = strlen(arg[0]) + 1;
|
|
|
|
integrate_style = new char[n];
|
|
|
|
strcpy(integrate_style,arg[0]);
|
|
|
|
}
|
|
|
|
}
|
2011-05-21 00:16:34 +08:00
|
|
|
|
2011-05-23 22:04:44 +08:00
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
create the Integrate style, first with suffix appended
|
|
|
|
------------------------------------------------------------------------- */
|
2011-05-21 00:16:34 +08:00
|
|
|
|
2011-05-21 01:33:20 +08:00
|
|
|
void Update::new_integrate(char *style, int narg, char **arg,
|
2014-08-15 00:30:03 +08:00
|
|
|
int trysuffix, int &sflag)
|
2011-05-21 01:33:20 +08:00
|
|
|
{
|
2014-08-15 00:30:03 +08:00
|
|
|
if (trysuffix && lmp->suffix_enable) {
|
|
|
|
if (lmp->suffix) {
|
|
|
|
sflag = 1;
|
|
|
|
char estyle[256];
|
|
|
|
sprintf(estyle,"%s/%s",style,lmp->suffix);
|
|
|
|
int success = 1;
|
2011-05-23 22:04:44 +08:00
|
|
|
|
2014-08-15 00:30:03 +08:00
|
|
|
if (0) return;
|
2011-02-23 06:49:15 +08:00
|
|
|
|
|
|
|
#define INTEGRATE_CLASS
|
|
|
|
#define IntegrateStyle(key,Class) \
|
2014-08-15 00:30:03 +08:00
|
|
|
else if (strcmp(estyle,#key) == 0) integrate = new Class(lmp,narg,arg);
|
2011-02-23 06:49:15 +08:00
|
|
|
#include "style_integrate.h"
|
2011-05-21 00:35:26 +08:00
|
|
|
#undef IntegrateStyle
|
2011-02-23 06:49:15 +08:00
|
|
|
#undef INTEGRATE_CLASS
|
2014-08-15 00:30:03 +08:00
|
|
|
|
|
|
|
else success = 0;
|
|
|
|
if (success) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lmp->suffix2) {
|
|
|
|
sflag = 2;
|
|
|
|
char estyle[256];
|
|
|
|
sprintf(estyle,"%s/%s",style,lmp->suffix2);
|
|
|
|
int success = 1;
|
|
|
|
|
|
|
|
if (0) return;
|
2011-02-23 06:49:15 +08:00
|
|
|
|
2014-08-15 00:30:03 +08:00
|
|
|
#define INTEGRATE_CLASS
|
|
|
|
#define IntegrateStyle(key,Class) \
|
|
|
|
else if (strcmp(estyle,#key) == 0) integrate = new Class(lmp,narg,arg);
|
|
|
|
#include "style_integrate.h"
|
|
|
|
#undef IntegrateStyle
|
|
|
|
#undef INTEGRATE_CLASS
|
|
|
|
|
|
|
|
else success = 0;
|
|
|
|
if (success) return;
|
|
|
|
}
|
2011-05-21 00:16:34 +08:00
|
|
|
}
|
|
|
|
|
2014-08-15 00:30:03 +08:00
|
|
|
sflag = 0;
|
|
|
|
if (0) return;
|
2011-05-21 00:16:34 +08:00
|
|
|
|
|
|
|
#define INTEGRATE_CLASS
|
|
|
|
#define IntegrateStyle(key,Class) \
|
2014-08-15 00:30:03 +08:00
|
|
|
else if (strcmp(style,#key) == 0) integrate = new Class(lmp,narg,arg);
|
2011-05-21 00:16:34 +08:00
|
|
|
#include "style_integrate.h"
|
2011-05-21 00:35:26 +08:00
|
|
|
#undef IntegrateStyle
|
2011-05-21 00:16:34 +08:00
|
|
|
#undef INTEGRATE_CLASS
|
|
|
|
|
2014-08-15 00:30:03 +08:00
|
|
|
else error->all(FLERR,"Illegal integrate style");
|
2011-02-23 06:49:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Update::create_minimize(int narg, char **arg)
|
|
|
|
{
|
2011-09-24 02:06:55 +08:00
|
|
|
if (narg != 1) error->all(FLERR,"Illegal min_style command");
|
2011-02-23 06:49:15 +08:00
|
|
|
|
|
|
|
delete [] minimize_style;
|
|
|
|
delete minimize;
|
|
|
|
|
|
|
|
if (0) return; // dummy line to enable else-if macro expansion
|
|
|
|
|
|
|
|
#define MINIMIZE_CLASS
|
|
|
|
#define MinimizeStyle(key,Class) \
|
|
|
|
else if (strcmp(arg[0],#key) == 0) minimize = new Class(lmp);
|
|
|
|
#include "style_minimize.h"
|
|
|
|
#undef MINIMIZE_CLASS
|
|
|
|
|
2011-09-24 02:06:55 +08:00
|
|
|
else error->all(FLERR,"Illegal min_style command");
|
2011-02-23 06:49:15 +08:00
|
|
|
|
|
|
|
int n = strlen(arg[0]) + 1;
|
|
|
|
minimize_style = new char[n];
|
|
|
|
strcpy(minimize_style,arg[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
2012-06-06 07:48:09 +08:00
|
|
|
reset timestep as called from input script
|
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Update::reset_timestep(int narg, char **arg)
|
|
|
|
{
|
|
|
|
if (narg != 1) error->all(FLERR,"Illegal reset_timestep command");
|
2015-01-21 07:25:40 +08:00
|
|
|
bigint newstep = force->bnumeric(FLERR,arg[0]);
|
2012-06-06 07:48:09 +08:00
|
|
|
reset_timestep(newstep);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
reset timestep
|
2012-06-29 07:53:36 +08:00
|
|
|
called from rerun command and input script (indirectly)
|
2011-02-23 06:49:15 +08:00
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
2012-06-06 07:48:09 +08:00
|
|
|
void Update::reset_timestep(bigint newstep)
|
2011-02-23 06:49:15 +08:00
|
|
|
{
|
2012-06-08 07:51:09 +08:00
|
|
|
ntimestep = newstep;
|
|
|
|
if (ntimestep < 0) error->all(FLERR,"Timestep must be >= 0");
|
2012-05-26 06:14:42 +08:00
|
|
|
|
2014-07-23 00:01:00 +08:00
|
|
|
// set atimestep to new timestep
|
|
|
|
// so future update_time() calls will be correct
|
|
|
|
|
2013-05-24 01:34:29 +08:00
|
|
|
atimestep = ntimestep;
|
|
|
|
|
2015-03-24 23:34:07 +08:00
|
|
|
// trigger reset of timestep for output
|
2015-02-11 00:18:21 +08:00
|
|
|
// do not allow any timestep-dependent fixes to be already defined
|
2014-07-23 00:01:00 +08:00
|
|
|
|
2012-06-08 07:51:09 +08:00
|
|
|
output->reset_timestep(ntimestep);
|
2011-02-23 06:49:15 +08:00
|
|
|
|
2012-06-08 07:51:09 +08:00
|
|
|
for (int i = 0; i < modify->nfix; i++) {
|
2011-02-23 06:49:15 +08:00
|
|
|
if (modify->fix[i]->time_depend)
|
2012-05-26 06:14:42 +08:00
|
|
|
error->all(FLERR,
|
2012-06-07 06:47:51 +08:00
|
|
|
"Cannot reset timestep with a time-dependent fix defined");
|
2012-06-08 07:51:09 +08:00
|
|
|
}
|
2011-02-23 06:49:15 +08:00
|
|
|
|
2014-07-23 00:01:00 +08:00
|
|
|
// reset eflag/vflag global so no commands will think eng/virial are current
|
|
|
|
|
2011-02-23 06:49:15 +08:00
|
|
|
eflag_global = vflag_global = -1;
|
|
|
|
|
2014-07-23 00:01:00 +08:00
|
|
|
// reset invoked flags of computes,
|
|
|
|
// so no commands will think they are current between runs
|
|
|
|
|
2011-02-23 06:49:15 +08:00
|
|
|
for (int i = 0; i < modify->ncompute; i++) {
|
|
|
|
modify->compute[i]->invoked_scalar = -1;
|
|
|
|
modify->compute[i]->invoked_vector = -1;
|
|
|
|
modify->compute[i]->invoked_array = -1;
|
|
|
|
modify->compute[i]->invoked_peratom = -1;
|
|
|
|
modify->compute[i]->invoked_local = -1;
|
|
|
|
}
|
|
|
|
|
2014-07-23 00:01:00 +08:00
|
|
|
// clear timestep list of computes that store future invocation times
|
|
|
|
|
2011-02-23 06:49:15 +08:00
|
|
|
for (int i = 0; i < modify->ncompute; i++)
|
|
|
|
if (modify->compute[i]->timeflag) modify->compute[i]->clearstep();
|
|
|
|
|
2014-07-23 00:01:00 +08:00
|
|
|
// set last_build of all neigh lists to -1 to force rebuild
|
|
|
|
|
|
|
|
for (int i = 0; i < neighbor->nlist; i++)
|
|
|
|
neighbor->lists[i]->last_build = -1;
|
|
|
|
|
2012-06-08 07:51:09 +08:00
|
|
|
// NOTE: 7Jun12, adding rerun command, don't think this is required
|
|
|
|
|
|
|
|
//for (int i = 0; i < domain->nregion; i++)
|
|
|
|
// if (domain->regions[i]->dynamic_check())
|
|
|
|
// error->all(FLERR,"Cannot reset timestep with a dynamic region defined");
|
2011-02-23 06:49:15 +08:00
|
|
|
}
|
|
|
|
|
2013-05-24 01:34:29 +08:00
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
update elapsed simulation time
|
|
|
|
called at end of runs or when timestep size changes
|
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Update::update_time()
|
|
|
|
{
|
|
|
|
atime += (ntimestep-atimestep) * dt;
|
|
|
|
atimestep = ntimestep;
|
|
|
|
}
|
|
|
|
|
2011-02-23 06:49:15 +08:00
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
memory usage of update and integrate/minimize
|
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
2011-03-17 04:03:49 +08:00
|
|
|
bigint Update::memory_usage()
|
2011-02-23 06:49:15 +08:00
|
|
|
{
|
2011-03-17 04:03:49 +08:00
|
|
|
bigint bytes = 0;
|
2011-02-23 06:49:15 +08:00
|
|
|
if (whichflag == 1) bytes += integrate->memory_usage();
|
|
|
|
else if (whichflag == 2) bytes += minimize->memory_usage();
|
|
|
|
return bytes;
|
|
|
|
}
|