forked from lijiext/lammps
git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5002 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
parent
addd9d7dad
commit
601a8c6270
|
@ -19,6 +19,7 @@
|
|||
#include "atom_vec.h"
|
||||
#include "comm.h"
|
||||
#include "modify.h"
|
||||
#include "fix.h"
|
||||
#include "domain.h"
|
||||
#include "lattice.h"
|
||||
#include "region.h"
|
||||
|
@ -151,6 +152,16 @@ void CreateAtoms::command(int narg, char **arg)
|
|||
else if (style == RANDOM) add_random();
|
||||
else add_lattice();
|
||||
|
||||
// invoke set_arrays() for fixes that need initialization of new atoms
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
for (int m = 0; m < modify->nfix; m++) {
|
||||
Fix *fix = modify->fix[m];
|
||||
if (fix->create_attribute)
|
||||
for (int i = nlocal_previous; i < nlocal; i++)
|
||||
fix->set_arrays(i);
|
||||
}
|
||||
|
||||
// clean up
|
||||
|
||||
if (domain->lattice) delete [] basistype;
|
||||
|
|
|
@ -47,6 +47,7 @@ FixMove::FixMove(LAMMPS *lmp, int narg, char **arg) :
|
|||
peratom_freq = 1;
|
||||
time_integrate = 1;
|
||||
time_depend = 1;
|
||||
create_attribute = 1;
|
||||
|
||||
// parse args
|
||||
|
||||
|
@ -847,6 +848,78 @@ void FixMove::copy_arrays(int i, int j)
|
|||
xoriginal[j][2] = xoriginal[i][2];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
initialize one atom's array values, called when atom is created
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixMove::set_arrays(int i)
|
||||
{
|
||||
double **x = atom->x;
|
||||
int *image = atom->image;
|
||||
int *mask = atom->mask;
|
||||
|
||||
// particle not in group
|
||||
|
||||
if (!(mask[i] & groupbit)) {
|
||||
xoriginal[i][0] = xoriginal[i][1] = xoriginal[i][2] = 0.0;
|
||||
return;
|
||||
}
|
||||
|
||||
// current time still equal fix creation time
|
||||
|
||||
if (update->ntimestep == time_origin) {
|
||||
domain->unmap(x[i],image[i],xoriginal[i]);
|
||||
return;
|
||||
}
|
||||
|
||||
// backup particle to time_origin
|
||||
|
||||
if (mstyle == VARIABLE)
|
||||
error->all("Cannot add atoms to fix move variable after");
|
||||
|
||||
domain->unmap(x[i],image[i],xoriginal[i]);
|
||||
double delta = (update->ntimestep - time_origin) * update->dt;
|
||||
|
||||
if (mstyle == LINEAR) {
|
||||
if (vxflag) xoriginal[i][0] -= vx * delta;
|
||||
if (vyflag) xoriginal[i][1] -= vy * delta;
|
||||
if (vzflag) xoriginal[i][2] -= vz * delta;
|
||||
} else if (mstyle == WIGGLE) {
|
||||
double arg = omega_rotate * delta;
|
||||
double sine = sin(arg);
|
||||
double cosine = cos(arg);
|
||||
if (axflag) xoriginal[i][0] -= ax*sine;
|
||||
if (ayflag) xoriginal[i][1] -= ay*sine;
|
||||
if (azflag) xoriginal[i][2] -= az*sine;
|
||||
} else if (mstyle == ROTATE) {
|
||||
double a[3],b[3],c[3],d[3],disp[3],ddotr;
|
||||
double arg = - omega_rotate * delta;
|
||||
double sine = sin(arg);
|
||||
double cosine = cos(arg);
|
||||
d[0] = x[i][0] - point[0];
|
||||
d[1] = x[i][1] - point[1];
|
||||
d[2] = x[i][2] - point[2];
|
||||
ddotr = d[0]*runit[0] + d[1]*runit[1] + d[2]*runit[2];
|
||||
c[0] = ddotr*runit[0];
|
||||
c[1] = ddotr*runit[1];
|
||||
c[2] = ddotr*runit[2];
|
||||
|
||||
a[0] = d[0] - c[0];
|
||||
a[1] = d[1] - c[1];
|
||||
a[2] = d[2] - c[2];
|
||||
b[0] = runit[1]*a[2] - runit[2]*a[1];
|
||||
b[1] = runit[2]*a[0] - runit[0]*a[2];
|
||||
b[2] = runit[0]*a[1] - runit[1]*a[0];
|
||||
disp[0] = a[0]*cosine + b[0]*sine;
|
||||
disp[1] = a[1]*cosine + b[1]*sine;
|
||||
disp[2] = a[2]*cosine + b[2]*sine;
|
||||
|
||||
xoriginal[i][0] = point[0] + c[0] + disp[0];
|
||||
xoriginal[i][1] = point[1] + c[1] + disp[1];
|
||||
xoriginal[i][2] = point[2] + c[2] + disp[2];
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack values in local atom-based array for exchange with another proc
|
||||
------------------------------------------------------------------------- */
|
||||
|
@ -920,3 +993,10 @@ int FixMove::size_restart(int nlocal)
|
|||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixMove::reset_dt()
|
||||
{
|
||||
error->all("Resetting timestep is not allowed with fix move");
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ class FixMove : public Fix {
|
|||
void restart(char *);
|
||||
void grow_arrays(int);
|
||||
void copy_arrays(int, int);
|
||||
void set_arrays(int);
|
||||
int pack_exchange(int, double *);
|
||||
int unpack_exchange(int, double *);
|
||||
int pack_restart(int, double *);
|
||||
|
@ -48,6 +49,8 @@ class FixMove : public Fix {
|
|||
int maxsize_restart();
|
||||
int size_restart(int);
|
||||
|
||||
void reset_dt();
|
||||
|
||||
private:
|
||||
char *xvarstr,*yvarstr,*zvarstr,*vxvarstr,*vyvarstr,*vzvarstr;
|
||||
int mstyle;
|
||||
|
|
Loading…
Reference in New Issue