git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@15109 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -47,6 +47,7 @@ FixSpring::FixSpring(LAMMPS *lmp, int narg, char **arg) :
|
||||
global_freq = 1;
|
||||
extscalar = 1;
|
||||
extvector = 1;
|
||||
dynamic_group_allow = 1;
|
||||
|
||||
group2 = NULL;
|
||||
|
||||
@ -166,6 +167,10 @@ void FixSpring::post_force(int vflag)
|
||||
void FixSpring::spring_tether()
|
||||
{
|
||||
double xcm[3];
|
||||
|
||||
if (group->dynamic[igroup])
|
||||
masstotal = group->mass(igroup);
|
||||
|
||||
group->xcm(igroup,masstotal,xcm);
|
||||
|
||||
// fx,fy,fz = components of k * (r-r0) / masstotal
|
||||
@ -192,9 +197,11 @@ void FixSpring::spring_tether()
|
||||
if (dr < 0.0) ftotal[3] = -ftotal[3];
|
||||
espring = 0.5*k_spring * dr*dr;
|
||||
|
||||
fx /= masstotal;
|
||||
fy /= masstotal;
|
||||
fz /= masstotal;
|
||||
if (masstotal > 0.0) {
|
||||
fx /= masstotal;
|
||||
fy /= masstotal;
|
||||
fz /= masstotal;
|
||||
}
|
||||
|
||||
// apply restoring force to atoms in group
|
||||
|
||||
@ -231,6 +238,13 @@ void FixSpring::spring_tether()
|
||||
void FixSpring::spring_couple()
|
||||
{
|
||||
double xcm[3],xcm2[3];
|
||||
|
||||
if (group->dynamic[igroup])
|
||||
masstotal = group->mass(igroup);
|
||||
|
||||
if (group->dynamic[igroup2])
|
||||
masstotal2 = group->mass(igroup2);
|
||||
|
||||
group->xcm(igroup,masstotal,xcm);
|
||||
group->xcm(igroup2,masstotal2,xcm2);
|
||||
|
||||
@ -259,12 +273,16 @@ void FixSpring::spring_couple()
|
||||
if (dr < 0.0) ftotal[3] = -ftotal[3];
|
||||
espring = 0.5*k_spring * dr*dr;
|
||||
|
||||
fx2 = fx/masstotal2;
|
||||
fy2 = fy/masstotal2;
|
||||
fz2 = fz/masstotal2;
|
||||
fx /= masstotal;
|
||||
fy /= masstotal;
|
||||
fz /= masstotal;
|
||||
if (masstotal2 > 0.0) {
|
||||
fx2 = fx/masstotal2;
|
||||
fy2 = fy/masstotal2;
|
||||
fz2 = fz/masstotal2;
|
||||
}
|
||||
if (masstotal > 0.0) {
|
||||
fx /= masstotal;
|
||||
fy /= masstotal;
|
||||
fz /= masstotal;
|
||||
}
|
||||
|
||||
// apply restoring force to atoms in group
|
||||
// f = -k*(r-r0)*mass/masstotal
|
||||
|
||||
Reference in New Issue
Block a user