ALPS Project: lattice library

Header file: lattice/hypercubic.h

defines a template class hypercubic_lattice which makes a hypercubic finite lattice with open or periodic boundary conditions from an infinite lattice.

Synopsis

namespace alps {

template <class BASE>
class hypercubic_lattice : public BASE {
public:
typedef BASE parent_lattice_type;
typedef typename lattice_traits<parent_lattice_type>::unit_cell_type unit_cell_type;
typedef typename lattice_traits<parent_lattice_type>::cell_descriptor cell_descriptor;
typedef typename lattice_traits<parent_lattice_type>::offset_type offset_type;
typedef typename lattice_traits<parent_lattice_type>::basis_vector_iterator basis_vector_iterator;
typedef typename lattice_traits<parent_lattice_type>::vector_type vector_type;
typedef boundary_crossing boundary_crossing_type;
typedef std::size_t size_type;
typedef /*...*/ cell_iterator;
typedef /*...*/ momentum_iterator;

hypercubic_lattice();
hypercubic_lattice(const parent_lattice_type& p, size_type length, std::string bc="periodic");

template <class InputIterator>
hypercubic_lattice(const parent_lattice_type& p, InputIterator first, InputIterator last,
std::string bc="periodic" );

template <class InputIterator2>
hypercubic_lattice(const parent_lattice_type& p, size_type length,
InputIterator2 first2, InputIterator2 last2);

template <class InputIterator, class InputIterator2>
hypercubic_lattice(const parent_lattice_type& p, InputIterator first, InputIterator last,
InputIterator2 first2, InputIterator2 last2);

std::pair<cell_iterator,cell_iterator> cells() const;
size_type volume() const'
size_type index(const cell_descriptor& c) const;
bool on_lattice(const cell_descriptor& c) const;
cell_descriptor cell(offset_type o) const;
bool shift(offset_type& o,const offset_type& s) const;

const std::string& boundary(uint32_t dim) const;
const std::vector<std::string>& boundary() const;

uint32_t extent(uint32_t dim) const;
const offset_type& extent() const;

std::pair<momentum_iterator,momentum_iterator> momenta() const
};

template <class BASE>
struct lattice_traits<hypercubic_lattice<BASE> >
{
typedef typename hypercubic_lattice<BASE>::unit_cell_type unit_cell_type;
typedef typename hypercubic_lattice<BASE>::cell_descriptor cell_descriptor;
typedef typename hypercubic_lattice<BASE>::offset_type offset_type;
typedef typename hypercubic_lattice<BASE>::basis_vector_iterator basis_vector_iterator;
typedef typename hypercubic_lattice<BASE>::cell_iterator cell_iterator;
typedef typename hypercubic_lattice<BASE>::size_type size_type;
typedef typename hypercubic_lattice<BASE>::vector_type vector_type;
typedef typename hypercubic_lattice<BASE>::boundary_crossing_type boundary_crossing_type;
};

}

The hypercubic_lattice class

describes a finite hypercubic lattice and fulfills the CoordinateLattice and FiniteLatticerequirements.

Template parameters

It takes one template arguments, the base type of the lattice which has to fulfill the CoordinateLattice requirements.

Type definitions

typedef BASE parent_lattice_type;
typedef for the template parameter, which is also the lattice from which this type is derived.
typedef BASE parent_lattice_type;
typedef typename lattice_traits<parent_lattice_type>::unit_cell_type unit_cell_type;
typedef typename lattice_traits<parent_lattice_type>::cell_descriptor cell_descriptor;
typedef typename lattice_traits<parent_lattice_type>::offset_type offset_type;
typedef typename lattice_traits<parent_lattice_type>::basis_vector_iterator basis_vector_iterator;
typedef typename lattice_traits<parent_lattice_type>::vector_type vector_type;
these types are inherited from the parent lattice.
typedef boundary_crossing boundary_crossing_type;
as an implementation of a periodic lattice, the type for the boundary crossing property is defined.
typedef std::size_t size_type;  
an integral type appropriate to store the volume (number of cells) of the lattice.
typedef /*...*/ cell_iterator;
the type for const iterators over the cells of the finite lattice.
typedef /*...*/ momentum_iterator;
the type for const iterators over the momenta of the reciprocal finite lattice.

Constructors

hypercubic_lattice();
an empty lattice without any cells.
hypercubic_lattice(const parent_lattice_type& p, size_type length, std::string bc="periodic");
obtains the dimension from the infinite parent lattice p and creates a hypercubic lattice with extent length in each of the dimensions. The boundary conditions bc can be passed optionally and default to periodic.
template <class InputIterator>
hypercubic_lattice(const parent_lattice_type& p, InputIterator first, InputIterator last,
std::string bc="periodic" );
obtains the dimension from the infinite parent lattice p and creates a hypercubic lattice where the extent in each of the dimensions is given by a pair of iterators. The boundary conditions bc can be passed optionally and default to periodic.
template <class InputIterator2>
hypercubic_lattice(const parent_lattice_type& p, size_type length,
InputIterator2 first2, InputIterator2 last2);
obtains the dimension from the infinite parent lattice p and creates a hypercubic lattice with extent length in each of the dimensions. The boundary conditions for each of the dimensions are given by a pair of iterators.
  template <class InputIterator, class InputIterator2>
hypercubic_lattice(const parent_lattice_type& p, InputIterator first, InputIterator last,
InputIterator2 first2, InputIterator2 last2);
obtains the dimension from the infinite parent lattice p and creates a hypercubic lattice where the extent in each of the dimensions is given by a pair of iterators. The second pair of iterators gives the boundary conditions.

Member functions

in addition to those inherited from the parent lattice:
std::pair<cell_iterator,cell_iterator> cells() const;
returns a pair of iterators, pointing to the first and one past the last cell in the lattice.
size_type volume() const;
returns the volume (number of cells) in the lattice. This is the product of the extents in each of the dimensions.
size_type index(const cell_descriptor& c) const;
returns the index of a cell. Cells are numbered consecutively from 0, in the same order as the iterators.
bool on_lattice(const cell_descriptor& c) const;
checks whether a cell is on the finite lattice.
cell_descriptor cell(offset_type o) const;
returns a cell with a given offset. on_lattice can be used to check whether this cell is on the finite lattice or outside.
bool shift(offset_type& o,const offset_type& s) const;
shifts a cell by an offset s, taking into account the boundary conditions and returns true if the shifted cell is on the finite lattice.
boundary_condition boundary(uint32_t dim) const;
returns the boundary condition for one of the dimensions. 0< dim < dimension(lattice)-1
const std::vector<boundary_condition>& boundary() const;
returns a vector of the boundary conditions for all dimensions.
uint32_t extent(uint32_t dim) const;
returns the extent for one of the dimensions. 0< dim < dimension(lattice)-1
const offset_type& extent() const;
returns a vector of the extent for all dimensions.
 std::pair<momentum_iterator,momentum_iterator> momenta() const
returns a pair of iterators over the momenta in reciprocal space of the finite lattice. Periodic boundary conditions in all directions are assumed for the determination of all momenta as otherwise they are not discreet. The value_type of the iterator is vector_type and the momenta are defined with respect to the reciprocal basis vectors of the lattice. Use the function momentum to convert these values to momenta in reciprocal space.

Traits class

template <class BASE>
struct lattice_traits<hypercubic_lattice<BASE> >
{
typedef typename hypercubic_lattice<BASE>::unit_cell_type unit_cell_type;
typedef typename hypercubic_lattice<BASE>::cell_descriptor cell_descriptor;
typedef typename hypercubic_lattice<BASE>::offset_type offset_type;
typedef typename hypercubic_lattice<BASE>::basis_vector_iterator basis_vector_iterator;
typedef typename hypercubic_lattice<BASE>::cell_iterator cell_iterator;
typedef typename hypercubic_lattice<BASE>::size_type size_type;
typedef typename hypercubic_lattice<BASE>::vector_type vector_type;
};
is the traits class for the lattice.

copyright (c) 1994-2010 by Matthias Troyer

Distributed under the Boost Software License, Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt)