NAMD
Public Member Functions | List of all members
PressureProfileReduction Class Reference

Public Member Functions

 PressureProfileReduction (int rtag, int numslabs, int numpartitions, const char *myname, int outputfreq)
 
 ~PressureProfileReduction ()
 
void getData (int firsttimestep, int step, const Lattice &lattice, BigReal *total)
 

Detailed Description

Definition at line 62 of file Controller.C.

Constructor & Destructor Documentation

PressureProfileReduction::PressureProfileReduction ( int  rtag,
int  numslabs,
int  numpartitions,
const char *  myname,
int  outputfreq 
)
inline

Definition at line 74 of file Controller.C.

References ReductionMgr::Object(), and ReductionMgr::willRequire().

76  : nslabs(numslabs), freq(outputfreq) {
77  name = strdup(myname);
78  nelements = 3*nslabs * numpartitions;
79  reduction = ReductionMgr::Object()->willRequire(rtag,nelements);
80 
81  average = new BigReal[nelements];
82  count = 0;
83  }
static ReductionMgr * Object(void)
Definition: ReductionMgr.h:278
RequireReduction * willRequire(int setID, int size=-1)
Definition: ReductionMgr.C:526
double BigReal
Definition: common.h:112
int average(CompAtom *qtilde, const HGArrayVector &q, BigReal *lambda, const int n, const int m, const HGArrayBigReal &imass, const HGArrayBigReal &length2, const HGArrayInt &ial, const HGArrayInt &ibl, const HGArrayVector &refab, const BigReal tolf, const int ntrial)
Definition: HomePatch.C:4490
PressureProfileReduction::~PressureProfileReduction ( )
inline

Definition at line 84 of file Controller.C.

84  {
85  delete [] average;
86  delete reduction;
87  free(name);
88  }
int average(CompAtom *qtilde, const HGArrayVector &q, BigReal *lambda, const int n, const int m, const HGArrayBigReal &imass, const HGArrayBigReal &length2, const HGArrayInt &ial, const HGArrayInt &ibl, const HGArrayVector &refab, const BigReal tolf, const int ntrial)
Definition: HomePatch.C:4490

Member Function Documentation

void PressureProfileReduction::getData ( int  firsttimestep,
int  step,
const Lattice lattice,
BigReal total 
)
inline

Definition at line 90 of file Controller.C.

References endi(), iout, RequireReduction::item(), PRESSUREFACTOR, RequireReduction::require(), and Lattice::volume().

Referenced by Controller::printEnergies().

91  {
92  reduction->require();
93 
94  int i;
95  double inv_volume = 1.0 / lattice.volume();
96  // accumulate the pressure profile computed for this step into the average.
97  int arraysize = 3*nslabs;
98  for (i=0; i<nelements; i++) {
99  BigReal val = reduction->item(i) * inv_volume;
100  average[i] += val;
101  total[i % arraysize] += val;
102  }
103  count++;
104  if (!(step % freq)) {
105  // convert NAMD internal virial to pressure in units of bar
106  BigReal scalefac = PRESSUREFACTOR * nslabs;
107 
108  iout << "PPROFILE" << name << ": " << step << " ";
109  if (step == firsttimestep) {
110  // output pressure profile for this step
111  for (i=0; i<nelements; i++)
112  iout << reduction->item(i)*scalefac*inv_volume << " ";
113  } else {
114  // output pressure profile averaged over the last Freq steps.
115  scalefac /= count;
116  for (i=0; i<nelements; i++)
117  iout << average[i]*scalefac << " ";
118  }
119  iout << "\n" << endi;
120  // Clear the average for the next block
121  memset(average, 0, nelements*sizeof(BigReal));
122  count = 0;
123  }
124  }
#define PRESSUREFACTOR
Definition: common.h:47
#define iout
Definition: InfoStream.h:87
void require(void)
Definition: ReductionMgr.h:341
BigReal volume(void) const
Definition: Lattice.h:277
BigReal item(int i) const
Definition: ReductionMgr.h:340
infostream & endi(infostream &s)
Definition: InfoStream.C:38
double BigReal
Definition: common.h:112
int average(CompAtom *qtilde, const HGArrayVector &q, BigReal *lambda, const int n, const int m, const HGArrayBigReal &imass, const HGArrayBigReal &length2, const HGArrayInt &ial, const HGArrayInt &ibl, const HGArrayVector &refab, const BigReal tolf, const int ntrial)
Definition: HomePatch.C:4490

The documentation for this class was generated from the following file: