QMCPACK
DTD_BConds< T, 2, SUPERCELL_BULK > Struct Template Reference

specialization for a periodic 2D cell More...

+ Collaboration diagram for DTD_BConds< T, 2, SUPERCELL_BULK >:

Public Member Functions

 DTD_BConds (const CrystalLattice< T, 2 > &lat)
 
get_min_distance (TinyVector< T, 2 > &a) const
 evaluate the minimum distance More...
 
apply_bc (TinyVector< T, 2 > &displ) const
 apply BC to a displacement vector a and return the minimum-image distance More...
 
void apply_bc (std::vector< TinyVector< T, 2 >> &dr, std::vector< T > &r, std::vector< T > &rinv) const
 
void apply_bc (std::vector< TinyVector< T, 2 >> &dr, std::vector< T > &r) const
 

Public Attributes

r00
 
r10
 
r01
 
r11
 
g00
 
g10
 
g01
 
g11
 
r2max
 
std::vector< TinyVector< T, 2 > > nextcells
 

Detailed Description

template<class T>
struct qmcplusplus::DTD_BConds< T, 2, SUPERCELL_BULK >

specialization for a periodic 2D cell

Definition at line 25 of file ParticleBConds2D.h.

Constructor & Destructor Documentation

◆ DTD_BConds()

DTD_BConds ( const CrystalLattice< T, 2 > &  lat)
inline

Definition at line 32 of file ParticleBConds2D.h.

33  : r00(lat.R(0)),
34  r10(lat.R(2)),
35  r01(lat.R(1)),
36  r11(lat.R(3)),
37  g00(lat.G(0)),
38  g10(lat.G(2)),
39  g01(lat.G(1)),
40  g11(lat.G(3)),
41  r2max(lat.CellRadiusSq)
42  {
43  nextcells.resize(8);
44  int ic = 0;
45  for (int i = -1; i <= 1; ++i)
46  for (int j = -1; j <= 1; ++j)
47  {
48  if (!(i || j))
49  continue; //exclude zero
50  nextcells[ic][0] = i * r00 + j * r10;
51  nextcells[ic][1] = i * r01 + j * r11;
52  ++ic;
53  }
54  }
std::vector< TinyVector< T, 2 > > nextcells

Member Function Documentation

◆ apply_bc() [1/3]

T apply_bc ( TinyVector< T, 2 > &  displ) const
inline

apply BC to a displacement vector a and return the minimum-image distance

Parameters
latlattice
adisplacement vector
Returns
the minimum-image distance

Definition at line 94 of file ParticleBConds2D.h.

95  {
96  //cart2unit
97  TinyVector<T, 2> ar(displ[0] * g00 + displ[1] * g10, displ[0] * g01 + displ[1] * g11);
98  //put them in the box
99  ar[0] -= round(ar[0]);
100  ar[1] -= round(ar[1]);
101  //unit2cart
102  displ[0] = ar[0] * r00 + ar[1] * r10;
103  displ[1] = ar[0] * r01 + ar[1] * r11;
104  //return |displ|^2 after checking the ghost cells
105  return get_min_distance(displ);
106  }
T get_min_distance(TinyVector< T, 2 > &a) const
evaluate the minimum distance

◆ apply_bc() [2/3]

void apply_bc ( std::vector< TinyVector< T, 2 >> &  dr,
std::vector< T > &  r,
std::vector< T > &  rinv 
) const
inline

Definition at line 108 of file ParticleBConds2D.h.

References DTD_BConds< T, D, SC >::apply_bc(), qmcplusplus::simd::inv(), qmcplusplus::n, and qmcplusplus::simd::sqrt().

109  {
110  const int n = dr.size();
111  for (int i = 0; i < n; ++i)
112  rinv[i] = apply_bc(dr[i]);
113  simd::sqrt(&rinv[0], &r[0], n);
114  simd::inv(&r[0], &rinv[0], n);
115  }
void inv(const T *restrict in, T *restrict out, int n)
Definition: vmath.hpp:65
T apply_bc(TinyVector< T, 2 > &displ) const
apply BC to a displacement vector a and return the minimum-image distance
void sqrt(T *restrict inout, SIZET n)
Definition: vmath.hpp:52

◆ apply_bc() [3/3]

void apply_bc ( std::vector< TinyVector< T, 2 >> &  dr,
std::vector< T > &  r 
) const
inline

Definition at line 117 of file ParticleBConds2D.h.

References DTD_BConds< T, D, SC >::apply_bc().

118  {
119  for (int i = 0; i < dr.size(); ++i)
120  r[i] = apply_bc(dr[i]);
121  }
T apply_bc(TinyVector< T, 2 > &displ) const
apply BC to a displacement vector a and return the minimum-image distance

◆ get_min_distance()

T get_min_distance ( TinyVector< T, 2 > &  a) const
inline

evaluate the minimum distance

Parameters
latlattice
adisplacement vector [-0.5,0.5)x[-0.5,0.5)x[-0.5,0.5)
r2maxsquare of the maximum cutoff
Returns
square of the minimum-image distance

Search the ghost cells to match Wigner-Seitz cell

Definition at line 64 of file ParticleBConds2D.h.

65  {
66  T d2 = a[0] * a[0] + a[1] * a[1];
67  if (d2 < r2max)
68  return d2;
69  else
70  {
71  T d2min = d2;
72  int ic = -1;
73  for (int i = 0; i < 8; ++i)
74  {
75  TinyVector<T, 2> c(a + nextcells[i]);
76  d2 = c[0] * c[0] + c[1] * c[1];
77  if (d2 < d2min)
78  {
79  d2min = d2;
80  ic = i;
81  }
82  }
83  if (ic >= 0)
84  a += nextcells[ic];
85  return d2min;
86  }
87  }
std::vector< TinyVector< T, 2 > > nextcells

Member Data Documentation

◆ g00

T g00

Definition at line 28 of file ParticleBConds2D.h.

◆ g01

T g01

Definition at line 28 of file ParticleBConds2D.h.

◆ g10

T g10

Definition at line 28 of file ParticleBConds2D.h.

◆ g11

T g11

Definition at line 28 of file ParticleBConds2D.h.

◆ nextcells

std::vector<TinyVector<T, 2> > nextcells

Definition at line 30 of file ParticleBConds2D.h.

◆ r00

T r00

Definition at line 27 of file ParticleBConds2D.h.

◆ r01

T r01

Definition at line 27 of file ParticleBConds2D.h.

◆ r10

T r10

Definition at line 27 of file ParticleBConds2D.h.

◆ r11

T r11

Definition at line 27 of file ParticleBConds2D.h.

◆ r2max

T r2max

Definition at line 29 of file ParticleBConds2D.h.


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