forked from lijiext/lammps
Moved compute_vsum into fix_msst
git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@4282 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
parent
c8478b7b66
commit
441180782e
|
@ -3,17 +3,13 @@
|
|||
if (test $1 = 1) then
|
||||
|
||||
cp fix_msst.cpp ..
|
||||
cp compute_vsum.cpp ..
|
||||
|
||||
cp fix_msst.h ..
|
||||
cp compute_vsum.h ..
|
||||
|
||||
elif (test $1 = 0) then
|
||||
|
||||
rm ../fix_msst.cpp
|
||||
rm ../compute_vsum.cpp
|
||||
|
||||
rm ../fix_msst.h
|
||||
rm ../compute_vsum.h
|
||||
|
||||
fi
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
certain rights in this software. This software is distributed under
|
||||
the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "mpi.h"
|
||||
#include "compute_vsum.h"
|
||||
#include "atom.h"
|
||||
#include "force.h"
|
||||
#include "modify.h"
|
||||
#include "fix.h"
|
||||
#include "group.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeVsum::ComputeVsum(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg != 3) error->all("Illegal compute temp command");
|
||||
|
||||
scalar_flag = vector_flag = 1;
|
||||
size_vector = 6;
|
||||
extscalar = 0;
|
||||
tempflag = 1;
|
||||
|
||||
vector = new double[6];
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeVsum::~ComputeVsum()
|
||||
{
|
||||
delete [] vector;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeVsum::init()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
double ComputeVsum::compute_scalar()
|
||||
{
|
||||
double **v = atom->v;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
double t = 0.0;
|
||||
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) {
|
||||
t += (v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]) ;
|
||||
}
|
||||
}
|
||||
|
||||
MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world);
|
||||
return scalar;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
certain rights in this software. This software is distributed under
|
||||
the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
// Compute the sum of the squared velocities, without usual mass terms
|
||||
// for the kinetic energy. This is used for the MSST (Larry Fried).
|
||||
|
||||
#ifdef COMPUTE_CLASS
|
||||
|
||||
ComputeStyle(vsum,ComputeVsum)
|
||||
|
||||
#else
|
||||
|
||||
#ifndef COMPUTE_VSUM_H
|
||||
#define COMPUTE_VSUM_H
|
||||
|
||||
#include "compute.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class ComputeVsum : public Compute {
|
||||
public:
|
||||
ComputeVsum(class LAMMPS *, int, char **);
|
||||
~ComputeVsum();
|
||||
void init();
|
||||
double compute_scalar();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -247,20 +247,6 @@ FixMSST::FixMSST(LAMMPS *lmp, int narg, char **arg) :
|
|||
delete [] newarg;
|
||||
peflag = 1;
|
||||
|
||||
// add a compute for the sum of the squared velocities.
|
||||
|
||||
n = strlen(id) + 6;
|
||||
id_vsum = new char[n];
|
||||
strcpy(id_vsum,id);
|
||||
strcat(id_vsum,"_vsum");
|
||||
newarg = new char*[3];
|
||||
newarg[0] = id_vsum;
|
||||
newarg[1] = "all";
|
||||
newarg[2] = "vsum";
|
||||
modify->add_compute(3,newarg);
|
||||
delete [] newarg;
|
||||
vsflag = 1;
|
||||
|
||||
// initialize the time derivative of the volume.
|
||||
omega[0] = omega[1] = omega[2] = 0.0;
|
||||
|
||||
|
@ -286,12 +272,10 @@ FixMSST::~FixMSST()
|
|||
if (tflag) modify->delete_compute(id_temp);
|
||||
if (pflag) modify->delete_compute(id_press);
|
||||
if (peflag) modify->delete_compute(id_pe);
|
||||
if (vsflag) modify->delete_compute(id_vsum);
|
||||
|
||||
delete [] id_temp;
|
||||
delete [] id_press;
|
||||
delete [] id_pe;
|
||||
delete [] id_vsum;
|
||||
|
||||
for ( int j = 0; j < atoms_allocated; j++ ) {
|
||||
delete [] old_velocity[j];
|
||||
|
@ -332,10 +316,6 @@ void FixMSST::init()
|
|||
if (icompute < 0) error->all("PE ID for fix msst does not exist");
|
||||
pe = modify->compute[icompute];
|
||||
|
||||
icompute = modify->find_compute(id_vsum);
|
||||
if ( icompute < 0 ) error->all("Vsum ID for fix msst does not exist");
|
||||
vsum = modify->compute[icompute];
|
||||
|
||||
dtv = update->dt;
|
||||
dtf = 0.5 * update->dt * force->ftm2v;
|
||||
dthalf = 0.5 * update->dt;
|
||||
|
@ -383,7 +363,7 @@ void FixMSST::setup(int vflag)
|
|||
temperature->compute_vector();
|
||||
pressure->compute_vector();
|
||||
couple();
|
||||
velocity_sum = vsum->compute_scalar();
|
||||
velocity_sum = compute_vsum();
|
||||
|
||||
if ( v0_set == 0 ) {
|
||||
v0 = compute_vol();
|
||||
|
@ -531,7 +511,7 @@ void FixMSST::initial_integrate(int vflag)
|
|||
// propagate velocity sum 1/2 step by
|
||||
// temporarily propagating the velocities.
|
||||
|
||||
velocity_sum = vsum->compute_scalar();
|
||||
velocity_sum = compute_vsum();
|
||||
for (i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) {
|
||||
for ( k = 0; k < 3; k++ ) {
|
||||
|
@ -552,7 +532,7 @@ void FixMSST::initial_integrate(int vflag)
|
|||
}
|
||||
}
|
||||
}
|
||||
velocity_sum = vsum->compute_scalar();
|
||||
velocity_sum = compute_vsum();
|
||||
|
||||
// reset the velocities.
|
||||
|
||||
|
@ -665,7 +645,7 @@ void FixMSST::final_integrate()
|
|||
|
||||
pressure->compute_vector();
|
||||
couple();
|
||||
velocity_sum = vsum->compute_scalar();
|
||||
velocity_sum = compute_vsum();
|
||||
vol = compute_vol();
|
||||
|
||||
// propagate the time derivative of the volume 1/2 step at fixed V, r, rdot.
|
||||
|
@ -1025,3 +1005,23 @@ void FixMSST::check_alloc(int n)
|
|||
}
|
||||
}
|
||||
|
||||
double FixMSST::compute_vsum()
|
||||
{
|
||||
double vsum;
|
||||
|
||||
double **v = atom->v;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
double t = 0.0;
|
||||
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) {
|
||||
t += (v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]) ;
|
||||
}
|
||||
}
|
||||
|
||||
MPI_Allreduce(&t,&vsum,1,MPI_DOUBLE,MPI_SUM,world);
|
||||
return vsum;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,11 +66,10 @@ class FixMSST : public Fix {
|
|||
int *rfix; // indices of rigid fixes
|
||||
|
||||
char *id_temp,*id_press; // Strings with identifiers of
|
||||
char *id_vsum, *id_pe; // created computes.
|
||||
char *id_pe; // created computes.
|
||||
|
||||
class Compute *temperature; // Computes created to evaluate
|
||||
class Compute *pressure; // thermodynamic quantities.
|
||||
class Compute *vsum;
|
||||
class Compute *pe;
|
||||
int tflag,pflag,vsflag,peflag; // Flags to keep track of computes that
|
||||
// were created.
|
||||
|
@ -100,6 +99,7 @@ class FixMSST : public Fix {
|
|||
double compute_rayleigh();
|
||||
double compute_lagrangian_speed();
|
||||
double compute_lagrangian_position();
|
||||
double compute_vsum();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue