Path Integral Quantum Monte Carlo
Public Member Functions
Prism Class Reference

A NDIM-dimensional hyperprism with periodic boundary conditions. More...

#include <container.h>

+ Inheritance diagram for Prism:
+ Collaboration diagram for Prism:

Public Member Functions

 Prism (const double, const int)
 Create a NDIM-dimensional hyperprism given density and number of particles. More...
 
 Prism (const dVec &, const iVec &_periodic=1)
 Create a NDIM-dimensional hyperprism given the edge sizes. More...
 
 ~Prism ()
 Empty destructor.
 
void putInside (dVec &r) const
 For PBC, this is identical to putInBC.
 
dVec randPosition (MTRand &) const
 Return a random position inside the cube.
 
dVec randUpdate (MTRand &, const dVec &) const
 Return a random position close to the supplied one.
 
int gridIndex (const dVec &) const
 Given a particle position, return a single integer which maps to a unique grid position. More...
 
double gridBoxVolume (const int) const
 Given a grid index, return the hyper volume of the associated grid box. More...
 
- Public Member Functions inherited from Container
 Container ()
 Initialize all variables.
 
virtual ~Container ()
 Empty destructor.
 
void putInBC (dVec &r) const
 Place a vector in boundary conditions. More...
 
void putInBC1 (dVec &r) const
 
double gridRadius2 (const int) const
 The radius of a grid box. More...
 

Additional Inherited Members

- Data Fields inherited from Container
TinyVector< unsigned int, NDIMperiodic
 Determines which dimensions have periodic bc.
 
dVec side
 The linear dimensions of the box.
 
dVec sideInv
 The inverse box dimensions.
 
dVec sideInv2
 2 times the inverse box dimensions
 
double volume
 The volume of the container in A^3.
 
double rcut2
 The smallest separation squared.
 
double maxSep
 The maximum possible separation for 2 beads on the same timeslice.
 
string name
 The name of the container.
 
int numGrid
 The number of grid boxes for the position grid.
 
bool fullyPeriodic
 Is the prism fully periodic?
 
dVec gridSize
 The grid size in each dimension.
 
- Protected Attributes inherited from Container
dVec pSide
 Periodic * side.
 

Detailed Description

A NDIM-dimensional hyperprism with periodic boundary conditions.

Definition at line 106 of file container.h.

Constructor & Destructor Documentation

◆ Prism() [1/2]

Prism::Prism ( const double  density,
const int  numParticles 
)

Create a NDIM-dimensional hyperprism given density and number of particles.

We create a NDIM hyperprism with periodic boundary conditions in all dimensions with a side that is set by the volume, given by the particle density in atoms/A^3 and the number of particles.

Definition at line 82 of file container.cpp.

82  {
83 
84  /* Here we can only create a cube */
85  /* Setup the cube size in each dimension */
86  side = pow(1.0*numParticles / density, 1.0/(1.0*NDIM));
87  sideInv = 1.0/side;
88  sideInv2 = 2.0*sideInv;
89 
90  rcut2 = 0.25*side[NDIM-1]*side[NDIM-1];
91 
92  /* The hyper cube has periodic boundary conditions */
93  periodic = 1;
94  pSide = side;
95  fullyPeriodic = true;
96 
97  /* Compute the maximum possible separation possible inside the box */
98  maxSep = sqrt(dot(side/(periodic + 1.0),side/(periodic + 1.0)));
99 
100  /* Calculate the volume of the cube */
101  volume = product(side);
102 
103  /* The grid size for the lookup table */
105 
106  name = "Prism";
107 }
dVec gridSize
The grid size in each dimension.
Definition: container.h:44
double volume
The volume of the container in A^3.
Definition: container.h:35
dVec sideInv
The inverse box dimensions.
Definition: container.h:32
dVec pSide
Periodic * side.
Definition: container.h:97
TinyVector< unsigned int, NDIM > periodic
Determines which dimensions have periodic bc.
Definition: container.h:29
dVec sideInv2
2 times the inverse box dimensions
Definition: container.h:33
double rcut2
The smallest separation squared.
Definition: container.h:36
string name
The name of the container.
Definition: container.h:39
bool fullyPeriodic
Is the prism fully periodic?
Definition: container.h:42
dVec side
The linear dimensions of the box.
Definition: container.h:31
double maxSep
The maximum possible separation for 2 beads on the same timeslice.
Definition: container.h:37
#define NDIM
Number of spatial dimnsions.
Definition: common.h:71
#define NGRIDSEP
Spatial separations to be used in each dimension of the particle position grid.
Definition: common.h:93

◆ Prism() [2/2]

Prism::Prism ( const dVec _side,
const iVec _periodic = 1 
)

Create a NDIM-dimensional hyperprism given the edge sizes.

We create a NDIM hyperprism with periodic boundary conditions in all dimensions with sides that are set at teh command line.

Definition at line 115 of file container.cpp.

115  {
116 
117  /* Setup the cube size in each dimension */
118  side = _side;
119  sideInv = 1.0/side;
120  sideInv2 = 2.0*sideInv;
121 
122  rcut2 = 0.25*side[NDIM-1]*side[NDIM-1];
123 
124  /* Setup the periodic boundary conditions */
125  periodic = _periodic;
126  pSide = periodic*side;
127 
128  /* are there any non-periodic boundary conditions? */
129  fullyPeriodic = all(periodic==1);
130 
131  /* Compute the maximum possible separation possible inside the box */
132  maxSep = sqrt(dot(side/(periodic + 1.0),side/(periodic + 1.0)));
133 
134  /* Calculate the volume of the cube */
135  volume = product(side);
136 
137  /* The grid size for the lookup table */
139 
140  name = "Prism";
141 }

Member Function Documentation

◆ gridBoxVolume()

double Prism::gridBoxVolume ( const int  n) const
virtual

Given a grid index, return the hyper volume of the associated grid box.

Parameters
nThe grid index
Returns
The hyper volume of the grid box

Implements Container.

Definition at line 212 of file container.cpp.

212  {
213  return blitz::product(gridSize);
214 }

◆ gridIndex()

int Prism::gridIndex ( const dVec pos) const
virtual

Given a particle position, return a single integer which maps to a unique grid position.

Used for correlating estimators with individual particle positions.

Parameters
posThe particle position
Returns
An integer representing a grid box number

Implements Container.

Definition at line 192 of file container.cpp.

192  {
193 
194  int gNumber = 0;
195  for (int i = 0; i < NDIM; i++) {
196  int scale = 1;
197  for (int j = i+1; j < NDIM; j++)
198  scale *= NGRIDSEP;
199  gNumber += scale *
200  static_cast<int>(abs( pos[i] + 0.5*side[i] - EPS ) / (gridSize[i] + EPS));
201  }
202  PIMC_ASSERT(gNumber<numGrid);
203  return gNumber;
204 }
int numGrid
The number of grid boxes for the position grid.
Definition: container.h:41
#define EPS
A small number.
Definition: common.h:94
#define PIMC_ASSERT(X)
Rename assert method.
Definition: common.h:64

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