~ubuntu-branches/debian/sid/lammps/sid

« back to all changes in this revision

Viewing changes to src/update.cpp

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2015-04-29 23:44:49 UTC
  • mfrom: (5.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20150429234449-mbhy9utku6hp6oq8
Tags: 0~20150313.gitfa668e1-1
Upload into unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include "style_integrate.h"
20
20
#include "style_minimize.h"
21
21
#include "neighbor.h"
 
22
#include "neigh_list.h"
22
23
#include "force.h"
23
24
#include "modify.h"
24
25
#include "fix.h"
61
62
  minimize = NULL;
62
63
 
63
64
  str = (char *) "verlet";
64
 
  create_integrate(1,&str,lmp->suffix);
 
65
  create_integrate(1,&str,1);
65
66
 
66
67
  str = (char *) "cg";
67
68
  create_minimize(1,&str);
234
235
    force->hhmrr2e = 0.0;
235
236
    force->mvh2r = 0.0;
236
237
    force->angstrom = 1.88972612;
237
 
    force->femtosecond = 0.0241888428;
 
238
    force->femtosecond = 41.34137413;
238
239
    force->qelectron = 1.0;
239
240
 
240
241
    dt = 0.001;
292
293
 
293
294
/* ---------------------------------------------------------------------- */
294
295
 
295
 
void Update::create_integrate(int narg, char **arg, char *suffix)
 
296
void Update::create_integrate(int narg, char **arg, int trysuffix)
296
297
{
297
298
  if (narg < 1) error->all(FLERR,"Illegal run_style command");
298
299
 
300
301
  delete integrate;
301
302
 
302
303
  int sflag;
303
 
  new_integrate(arg[0],narg-1,&arg[1],suffix,sflag);
 
304
  new_integrate(arg[0],narg-1,&arg[1],trysuffix,sflag);
304
305
 
305
306
  if (sflag) {
306
307
    char estyle[256];
307
 
    sprintf(estyle,"%s/%s",arg[0],suffix);
 
308
    if (sflag == 1) sprintf(estyle,"%s/%s",arg[0],lmp->suffix);
 
309
    else sprintf(estyle,"%s/%s",arg[0],lmp->suffix2);
308
310
    int n = strlen(estyle) + 1;
309
311
    integrate_style = new char[n];
310
312
    strcpy(integrate_style,estyle);
320
322
------------------------------------------------------------------------- */
321
323
 
322
324
void Update::new_integrate(char *style, int narg, char **arg,
323
 
                           char *suffix, int &sflag)
 
325
                           int trysuffix, int &sflag)
324
326
{
325
 
  int success = 0;
326
 
 
327
 
  if (suffix && lmp->suffix_enable) {
328
 
    sflag = 1;
329
 
    char estyle[256];
330
 
    sprintf(estyle,"%s/%s",style,suffix);
331
 
    success = 1;
332
 
 
333
 
    if (0) return;
334
 
 
335
 
#define INTEGRATE_CLASS
336
 
#define IntegrateStyle(key,Class) \
337
 
    else if (strcmp(estyle,#key) == 0) integrate = new Class(lmp,narg,arg);
338
 
#include "style_integrate.h"
339
 
#undef IntegrateStyle
340
 
#undef INTEGRATE_CLASS
341
 
 
342
 
    else success = 0;
343
 
  }
344
 
 
345
 
  if (!success) {
346
 
    sflag = 0;
347
 
 
348
 
    if (0) return;
349
 
 
350
 
#define INTEGRATE_CLASS
351
 
#define IntegrateStyle(key,Class) \
352
 
    else if (strcmp(style,#key) == 0) integrate = new Class(lmp,narg,arg);
353
 
#include "style_integrate.h"
354
 
#undef IntegrateStyle
355
 
#undef INTEGRATE_CLASS
356
 
 
357
 
    else error->all(FLERR,"Illegal integrate style");
358
 
  }
 
327
  if (trysuffix && lmp->suffix_enable) {
 
328
    if (lmp->suffix) {
 
329
      sflag = 1;
 
330
      char estyle[256];
 
331
      sprintf(estyle,"%s/%s",style,lmp->suffix);
 
332
      int success = 1;
 
333
 
 
334
      if (0) return;
 
335
 
 
336
#define INTEGRATE_CLASS
 
337
#define IntegrateStyle(key,Class) \
 
338
      else if (strcmp(estyle,#key) == 0) integrate = new Class(lmp,narg,arg);
 
339
#include "style_integrate.h"
 
340
#undef IntegrateStyle
 
341
#undef INTEGRATE_CLASS
 
342
      
 
343
      else success = 0;
 
344
      if (success) return;
 
345
    }
 
346
    
 
347
    if (lmp->suffix2) {
 
348
      sflag = 2;
 
349
      char estyle[256];
 
350
      sprintf(estyle,"%s/%s",style,lmp->suffix2);
 
351
      int success = 1;
 
352
 
 
353
      if (0) return;
 
354
 
 
355
#define INTEGRATE_CLASS
 
356
#define IntegrateStyle(key,Class) \
 
357
      else if (strcmp(estyle,#key) == 0) integrate = new Class(lmp,narg,arg);
 
358
#include "style_integrate.h"
 
359
#undef IntegrateStyle
 
360
#undef INTEGRATE_CLASS
 
361
      
 
362
      else success = 0;
 
363
      if (success) return;
 
364
    }
 
365
  }
 
366
 
 
367
  sflag = 0;
 
368
  if (0) return;
 
369
 
 
370
#define INTEGRATE_CLASS
 
371
#define IntegrateStyle(key,Class) \
 
372
  else if (strcmp(style,#key) == 0) integrate = new Class(lmp,narg,arg);
 
373
#include "style_integrate.h"
 
374
#undef IntegrateStyle
 
375
#undef INTEGRATE_CLASS
 
376
 
 
377
  else error->all(FLERR,"Illegal integrate style");
359
378
}
360
379
 
361
380
/* ---------------------------------------------------------------------- */
389
408
void Update::reset_timestep(int narg, char **arg)
390
409
{
391
410
  if (narg != 1) error->all(FLERR,"Illegal reset_timestep command");
392
 
  bigint newstep = ATOBIGINT(arg[0]);
 
411
  bigint newstep = force->bnumeric(FLERR,arg[0]);
393
412
  reset_timestep(newstep);
394
413
}
395
414
 
396
415
/* ----------------------------------------------------------------------
397
416
   reset timestep
398
 
   set atimestep to new timestep, so future update_time() calls will be correct
399
 
   trigger reset of timestep for output and for fixes that require it
400
 
   do not allow any timestep-dependent fixes to be defined
401
 
   reset eflag/vflag global so nothing will think eng/virial are current
402
 
   reset invoked flags of computes,
403
 
     so nothing will think they are current between runs
404
 
   clear timestep list of computes that store future invocation times
405
417
   called from rerun command and input script (indirectly)
406
418
------------------------------------------------------------------------- */
407
419
 
411
423
  if (ntimestep < 0) error->all(FLERR,"Timestep must be >= 0");
412
424
  if (ntimestep > MAXBIGINT) error->all(FLERR,"Too big a timestep");
413
425
 
 
426
  // set atimestep to new timestep
 
427
  // so future update_time() calls will be correct
 
428
 
414
429
  atimestep = ntimestep;
415
430
 
 
431
  // trigger reset of timestep for output and for fixes that require it
 
432
  // do not allow any timestep-dependent fixes to be already defined
 
433
 
416
434
  output->reset_timestep(ntimestep);
417
435
 
418
436
  for (int i = 0; i < modify->nfix; i++) {
422
440
    modify->fix[i]->reset_timestep(ntimestep);
423
441
  }
424
442
 
 
443
  // reset eflag/vflag global so no commands will think eng/virial are current
 
444
 
425
445
  eflag_global = vflag_global = -1;
426
446
 
 
447
  // reset invoked flags of computes,
 
448
  // so no commands will think they are current between runs
 
449
 
427
450
  for (int i = 0; i < modify->ncompute; i++) {
428
451
    modify->compute[i]->invoked_scalar = -1;
429
452
    modify->compute[i]->invoked_vector = -1;
432
455
    modify->compute[i]->invoked_local = -1;
433
456
  }
434
457
 
 
458
  // clear timestep list of computes that store future invocation times
 
459
 
435
460
  for (int i = 0; i < modify->ncompute; i++)
436
461
    if (modify->compute[i]->timeflag) modify->compute[i]->clearstep();
437
462
 
 
463
  // set last_build of all neigh lists to -1 to force rebuild
 
464
 
 
465
  for (int i = 0; i < neighbor->nlist; i++)
 
466
    neighbor->lists[i]->last_build = -1;
 
467
 
438
468
  // NOTE: 7Jun12, adding rerun command, don't think this is required
439
469
 
440
470
  //for (int i = 0; i < domain->nregion; i++)