34 for (
int i = 0; i <
NDIM; i++)
53 for (
int i = 0; i <
NDIM; i++) {
55 for (
int j = i+1; j <
NDIM; j++)
57 _gridIndex[i] = (n/scale) %
NGRIDSEP;
62 for (
int i = 0; i < 2; i++) {
63 double ri = -0.5*
side[i] + (_gridIndex[i] + 0.5)*
gridSize[i];
86 side = pow(1.0*numParticles / density, 1.0/(1.0*
NDIM));
154 for (
int i = 0; i <
NDIM; i++)
155 randPos[i] =
side[i]*(-0.5 + random.randExc());
165 for (
int i = 0; i <
NDIM; i++)
171 for (
int i = 0; i <
NDIM; i++) {
173 if (randPos[i] >= 0.5*
side[i])
174 randPos[i] = 0.5*
side[i] - 2*
EPS;
175 if (randPos[i] < -0.5*
side[i])
176 randPos[i] = -0.5*
side[i] + 2*
EPS;
195 for (
int i = 0; i <
NDIM; i++) {
197 for (
int j = i+1; j <
NDIM; j++)
233 cerr <<
"You can only create a cylinder in 3 dimensions, change NDIM!"
240 double L = (1.0*numParticles)/(_rho * M_PI * radius * radius);
244 cerr <<
"L:r is smaller than 2:1!" << endl;
268 volume = M_PI*radius*radius*L;
290 cerr <<
"You can only create a cylinder in 3 dimensions, change NDIM!"
297 cerr <<
"L:r is smaller than 2:1!" << endl;
322 volume = M_PI*radius*radius*L;
345 double r = 0.5*
side[0]*sqrt(random.randExc());
346 double phi = random.randExc(2.0*M_PI);
347 randPos[0] = r * cos(phi);
348 randPos[1] = r * sin(phi);
349 randPos[2] =
side[2]*(-0.5 + random.randExc());
359 if (random.rand() < 0.5)
372 double theta = atan2(pos[1],pos[0]);
373 double oldr = sqrt(pos[0]*pos[0] + pos[1]*pos[1]);
376 if (random.rand() > 0.5)
377 newr = oldr + (1.00 + 2.50*random.rand());
379 newr = oldr - (1.00 + 2.50*random.rand());
384 double ranTheta = M_PI*(-0.05 + 0.1*random.rand());
385 randPos[0] = newr*cos(theta + ranTheta);
386 randPos[1] = newr*sin(theta + ranTheta);
400 for (
int i = 0; i <
NDIM; i++)
411 for (
int i = 0; i <
NDIM-1; i++) {
412 if (r[i] >= 0.5*
side[i])
414 if (r[i] < -0.5*
side[i])
419 r[2] -= (r[2] >= 0.5*
side[2])*
side[2];
420 r[2] += (r[2] < -0.5*
side[2])*
side[2];
452 for (
int i = 0; i <
NDIM; i++) {
454 for (
int j = i+1; j <
NDIM; j++)
double displaceDelta() const
Get center of mass shift.
dVec gridSize
The grid size in each dimension.
Container()
Initialize all variables.
double volume
The volume of the container in A^3.
int numGrid
The number of grid boxes for the position grid.
dVec sideInv
The inverse box dimensions.
dVec pSide
Periodic * side.
TinyVector< unsigned int, NDIM > periodic
Determines which dimensions have periodic bc.
dVec sideInv2
2 times the inverse box dimensions
double gridRadius2(const int) const
The radius of a grid box.
double rcut2
The smallest separation squared.
string name
The name of the container.
bool fullyPeriodic
Is the prism fully periodic?
dVec side
The linear dimensions of the box.
virtual ~Container()
Empty destructor.
double maxSep
The maximum possible separation for 2 beads on the same timeslice.
dVec randUpdateJumpShell(MTRand &, const dVec &) const
Return a random position close to the supplied one.
dVec randUpdateSmall(MTRand &, const dVec &) const
Return a random position close to the supplied one.
Cylinder(const double, const double, const int)
Create a cylinder given density, radius and number of particles.
dVec randPosition(MTRand &) const
Return a random position inside the cylinder.
double gridBoxVolume(const int) const
Given a grid index, return the hyper volume of the associated grid box.
dVec randUpdate(MTRand &, const dVec &) const
Return a random position close to the supplied one.
void putInside(dVec &r) const
Make sure that a suplied vector is put inside the cylinder.
int gridIndex(const dVec &) const
Given a particle position, return a single integer which maps to a unique grid position.
double gridBoxVolume(const int) const
Given a grid index, return the hyper volume of the associated grid box.
~Prism()
Empty destructor.
dVec randPosition(MTRand &) const
Return a random position inside the cube.
Prism(const double, const int)
Create a NDIM-dimensional hyperprism given density and number of particles.
int gridIndex(const dVec &) const
Given a particle position, return a single integer which maps to a unique grid position.
void putInside(dVec &r) const
For PBC, this is identical to putInBC.
dVec randUpdate(MTRand &, const dVec &) const
Return a random position close to the supplied one.
#define NDIM
Number of spatial dimnsions.
#define EPS
A small number.
#define NGRIDSEP
Spatial separations to be used in each dimension of the particle position grid.
TinyVector< double, NDIM > dVec
A NDIM-vector of type double.
#define PIMC_ASSERT(X)
Rename assert method.
TinyVector< int, NDIM > iVec
A NDIM-vector of type integer.
ConstantParameters class definition.
ConstantParameters * constants()
Global public access to the constants.