git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@738 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
enum{CHUTE,SPHERICAL,GRADIENT,VECTOR};
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
FixGravity::FixGravity(LAMMPS *lmp, int narg, char **arg) :
|
FixGravity::FixGravity(LAMMPS *lmp, int narg, char **arg) :
|
||||||
@ -32,28 +34,24 @@ FixGravity::FixGravity(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
if (strcmp(arg[3],"chute") == 0) {
|
if (strcmp(arg[3],"chute") == 0) {
|
||||||
if (narg != 5) error->all("Illegal fix gravity command");
|
if (narg != 5) error->all("Illegal fix gravity command");
|
||||||
dynamic = 0;
|
style = CHUTE;
|
||||||
granular = 1;
|
|
||||||
phi = 0.0;
|
phi = 0.0;
|
||||||
theta = 180.0 - atof(arg[4]);
|
theta = 180.0 - atof(arg[4]);
|
||||||
} else if (strcmp(arg[3],"spherical") == 0) {
|
} else if (strcmp(arg[3],"spherical") == 0) {
|
||||||
if (narg != 6) error->all("Illegal fix gravity command");
|
if (narg != 6) error->all("Illegal fix gravity command");
|
||||||
dynamic = 0;
|
style = SPHERICAL;
|
||||||
granular = 1;
|
|
||||||
phi = atof(arg[4]);
|
phi = atof(arg[4]);
|
||||||
theta = atof(arg[5]);
|
theta = atof(arg[5]);
|
||||||
} else if (strcmp(arg[3],"gradient") == 0) {
|
} else if (strcmp(arg[3],"gradient") == 0) {
|
||||||
if (narg != 8) error->all("Illegal fix gravity command");
|
if (narg != 8) error->all("Illegal fix gravity command");
|
||||||
dynamic = 1;
|
style = GRADIENT;
|
||||||
granular = 1;
|
|
||||||
phi = atof(arg[4]);
|
phi = atof(arg[4]);
|
||||||
theta = atof(arg[5]);
|
theta = atof(arg[5]);
|
||||||
phigrad = atof(arg[6]);
|
phigrad = atof(arg[6]);
|
||||||
thetagrad = atof(arg[7]);
|
thetagrad = atof(arg[7]);
|
||||||
} else if (strcmp(arg[3],"vector") == 0) {
|
} else if (strcmp(arg[3],"vector") == 0) {
|
||||||
if (narg != 8) error->all("Illegal fix gravity command");
|
if (narg != 8) error->all("Illegal fix gravity command");
|
||||||
dynamic = 0;
|
style = VECTOR;
|
||||||
granular = 0;
|
|
||||||
magnitude = atof(arg[4]);
|
magnitude = atof(arg[4]);
|
||||||
xdir = atof(arg[5]);
|
xdir = atof(arg[5]);
|
||||||
ydir = atof(arg[6]);
|
ydir = atof(arg[6]);
|
||||||
@ -80,7 +78,7 @@ void FixGravity::init()
|
|||||||
{
|
{
|
||||||
dt = update->dt;
|
dt = update->dt;
|
||||||
|
|
||||||
if (granular) {
|
if (style == CHUTE || style == SPHERICAL || style == GRADIENT) {
|
||||||
if (domain->dimension == 3) {
|
if (domain->dimension == 3) {
|
||||||
xgrav = sin(degree2rad * theta) * cos(degree2rad * phi);
|
xgrav = sin(degree2rad * theta) * cos(degree2rad * phi);
|
||||||
ygrav = sin(degree2rad * theta) * sin(degree2rad * phi);
|
ygrav = sin(degree2rad * theta) * sin(degree2rad * phi);
|
||||||
@ -90,7 +88,7 @@ void FixGravity::init()
|
|||||||
ygrav = cos(degree2rad * theta);
|
ygrav = cos(degree2rad * theta);
|
||||||
zgrav = 0.0;
|
zgrav = 0.0;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (style == VECTOR) {
|
||||||
if (domain->dimension == 3) {
|
if (domain->dimension == 3) {
|
||||||
double length = sqrt(xdir*xdir + ydir*ydir + zdir*zdir);
|
double length = sqrt(xdir*xdir + ydir*ydir + zdir*zdir);
|
||||||
xgrav = magnitude * xdir/length;
|
xgrav = magnitude * xdir/length;
|
||||||
@ -116,9 +114,9 @@ void FixGravity::setup()
|
|||||||
|
|
||||||
void FixGravity::post_force(int vflag)
|
void FixGravity::post_force(int vflag)
|
||||||
{
|
{
|
||||||
// update direction of gravity vector if dynamic
|
// update direction of gravity vector if gradient style
|
||||||
|
|
||||||
if (dynamic) {
|
if (style == GRADIENT) {
|
||||||
double phi_current = degree2rad *
|
double phi_current = degree2rad *
|
||||||
(phi + (update->ntimestep-time_initial)*dt*phigrad*360.0);
|
(phi + (update->ntimestep-time_initial)*dt*phigrad*360.0);
|
||||||
double theta_current = degree2rad *
|
double theta_current = degree2rad *
|
||||||
|
|||||||
@ -30,8 +30,7 @@ FixGravity(class LAMMPS *, int, char **);
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
double phi,theta,phigrad,thetagrad;
|
double phi,theta,phigrad,thetagrad;
|
||||||
int dynamic,time_initial;
|
int style,time_initial;
|
||||||
int granular; // 0 if non-granular, 1 if granular
|
|
||||||
double magnitude,xdir,ydir,zdir;
|
double magnitude,xdir,ydir,zdir;
|
||||||
double dt;
|
double dt;
|
||||||
double xgrav,ygrav,zgrav;
|
double xgrav,ygrav,zgrav;
|
||||||
|
|||||||
Reference in New Issue
Block a user