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 108 of file Controller.C.

Constructor & Destructor Documentation

◆ PressureProfileReduction()

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

Definition at line 120 of file Controller.C.

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

122  : nslabs(numslabs), freq(outputfreq) {
123  name = strdup(myname);
124  nelements = 3*nslabs * numpartitions;
125  reduction = ReductionMgr::Object()->willRequire(rtag,nelements);
126 
127  average = new BigReal[nelements];
128  count = 0;
129  }
static ReductionMgr * Object(void)
Definition: ReductionMgr.h:279
RequireReduction * willRequire(int setID, int size=-1)
Definition: ReductionMgr.C:527
double BigReal
Definition: common.h:123
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:6464

◆ ~PressureProfileReduction()

PressureProfileReduction::~PressureProfileReduction ( )
inline

Definition at line 130 of file Controller.C.

References average().

130  {
131  delete [] average;
132  delete reduction;
133  free(name);
134  }
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:6464

Member Function Documentation

◆ getData()

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

Definition at line 136 of file Controller.C.

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

Referenced by Controller::printEnergies().

137  {
138  reduction->require();
139 
140  int i;
141  double inv_volume = 1.0 / lattice.volume();
142  // accumulate the pressure profile computed for this step into the average.
143  int arraysize = 3*nslabs;
144  for (i=0; i<nelements; i++) {
145  BigReal val = reduction->item(i) * inv_volume;
146  average[i] += val;
147  total[i % arraysize] += val;
148  }
149  count++;
150  if (!(step % freq)) {
151  // convert NAMD internal virial to pressure in units of bar
152  BigReal scalefac = PRESSUREFACTOR * nslabs;
153 
154  iout << "PPROFILE" << name << ": " << step << " ";
155  if (step == firsttimestep) {
156  // output pressure profile for this step
157  for (i=0; i<nelements; i++)
158  iout << reduction->item(i)*scalefac*inv_volume << " ";
159  } else {
160  // output pressure profile averaged over the last Freq steps.
161  scalefac /= count;
162  for (i=0; i<nelements; i++)
163  iout << average[i]*scalefac << " ";
164  }
165  iout << "\n" << endi;
166  // Clear the average for the next block
167  memset(average, 0, nelements*sizeof(BigReal));
168  count = 0;
169  }
170  }
#define PRESSUREFACTOR
Definition: common.h:56
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
#define iout
Definition: InfoStream.h:51
void require(void)
Definition: ReductionMgr.h:342
NAMD_HOST_DEVICE BigReal volume(void) const
Definition: Lattice.h:293
BigReal item(int i) const
Definition: ReductionMgr.h:341
double BigReal
Definition: common.h:123
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:6464

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