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

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

119  : nslabs(numslabs), freq(outputfreq) {
120  name = strdup(myname);
121  nelements = 3*nslabs * numpartitions;
122  reduction = ReductionMgr::Object()->willRequire(rtag,nelements);
123 
124  average = new BigReal[nelements];
125  count = 0;
126  }
static ReductionMgr * Object(void)
Definition: ReductionMgr.h:290
RequireReduction * willRequire(int setID, int size=-1)
Definition: ReductionMgr.C:539
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:6470

◆ ~PressureProfileReduction()

PressureProfileReduction::~PressureProfileReduction ( )
inline

Definition at line 127 of file Controller.C.

References average().

127  {
128  delete [] average;
129  delete reduction;
130  free(name);
131  }
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:6470

Member Function Documentation

◆ getData()

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

Definition at line 133 of file Controller.C.

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

Referenced by Controller::printEnergies().

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

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