Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
shammath::LatticeFCC< Tvec > Class Template Reference

utility for generating FCC (face-centered cubic) crystal lattices More...

#include <shammath/include/shammath/crystalLattice.hpp>

Public Types

using Tscal = shambase::VecComponent<Tvec>
using Iterator = iterator_utils::LatticeIterator<Tvec, LatticeFCC>
 Iterator utility to generate the lattice.
using IteratorDiscontinuous = iterator_utils::LatticeIteratorDiscontinuous<Tvec, LatticeFCC>
 Iterator utility to generate the lattice in a discontinuous order.

Static Public Member Functions

static constexpr i32 pmod (i32 a, i32 b) noexcept
 Positive modulo (C++ % keeps the sign of the dividend).
static constexpr Tvec generator (Tscal dr, std::array< i32, dim > coord) noexcept
 generate a FCC lattice centered on (0,0,0)
static constexpr bool can_make_periodic_box (std::array< i32, dim > coord_min, std::array< i32, dim > coord_max)
 check if the given lattice coordinates bounds can make a periodic box
static constexpr CoordRange< Tvec > get_periodic_box (Tscal dr, std::array< i32, dim > coord_min, std::array< i32, dim > coord_max)
 Get the periodic box corresponding to integer lattice coordinates this function will throw if the coordinates asked cannot make a periodic lattice.
static constexpr std::pair< std::array< i32, dim >, std::array< i32, dim > > get_box_index_bounds (Tscal dr, Tvec box_min, Tvec box_max)
 Get the lattice integer coordinates bounds covering the given box (with a one cell margin on each side).
static constexpr std::pair< std::array< i32, dim >, std::array< i32, dim > > nearest_periodic_box_indices (std::array< i32, dim > coord_min, std::array< i32, dim > coord_max)
 get the nearest integer triplets bound that gives a periodic box (by only increasing the upper bound)
static constexpr Tvec get_box_dim (Tscal dr, u32 xcnt, u32 ycnt, u32 zcnt)
 Get the box size for a FCC lattice of xcnt * ycnt * zcnt lattice cells this function will throw if the counts asked cannot make a periodic lattice.
static std::tuple< Tvec, Tvec > get_ideal_fcc_box (Tscal dr, std::tuple< Tvec, Tvec > box)
 Get the smallest periodic FCC box containing the given box.

Static Public Attributes

static constexpr u32 dim = 3
static constexpr i32 z_period = 3
 Number of layers after which the stacking sequence repeats along z.

Detailed Description

template<class Tvec>
class shammath::LatticeFCC< Tvec >

utility for generating FCC (face-centered cubic) crystal lattices

The lattice is built as a stack of close-packed triangular layers normal to the z axis following the ABCABC... stacking sequence (as opposed to LatticeHCP which uses the ABAB... sequence). Like LatticeHCP, neighbours are 2 dr apart, so both lattices share the same particle density and the same in-plane / inter-layer spacings, only the stacking differs.

Since the stacking repeats every 3 layers, a periodic box requires the number of layers along z to be a multiple of 3 (instead of 2 for HCP).

Template Parameters
Tvecposition vector type

Definition at line 441 of file crystalLattice.hpp.

Member Typedef Documentation

◆ Iterator

template<class Tvec>
using shammath::LatticeFCC< Tvec >::Iterator = iterator_utils::LatticeIterator<Tvec, LatticeFCC>

Iterator utility to generate the lattice.

Definition at line 601 of file crystalLattice.hpp.

◆ IteratorDiscontinuous

template<class Tvec>
using shammath::LatticeFCC< Tvec >::IteratorDiscontinuous = iterator_utils::LatticeIteratorDiscontinuous<Tvec, LatticeFCC>

Iterator utility to generate the lattice in a discontinuous order.

Definition at line 604 of file crystalLattice.hpp.

◆ Tscal

template<class Tvec>
using shammath::LatticeFCC< Tvec >::Tscal = shambase::VecComponent<Tvec>

Definition at line 448 of file crystalLattice.hpp.

Member Function Documentation

◆ can_make_periodic_box()

template<class Tvec>
constexpr bool shammath::LatticeFCC< Tvec >::can_make_periodic_box ( std::array< i32, dim > coord_min,
std::array< i32, dim > coord_max )
inlinestaticconstexpr

check if the given lattice coordinates bounds can make a periodic box

Parameters
coord_mininteger triplet for the minimal coordinates on the lattice
coord_maxinteger triplet for the maximal coordinates on the lattice
Returns
true
false

Definition at line 488 of file crystalLattice.hpp.

Here is the call graph for this function:

◆ generator()

template<class Tvec>
constexpr Tvec shammath::LatticeFCC< Tvec >::generator ( Tscal dr,
std::array< i32, dim > coord )
inlinestaticconstexprnoexcept

generate a FCC lattice centered on (0,0,0)

Layer k is the triangular layer A shifted by (k mod 3) * (1, 1/sqrt(3)) (in units of dr), which gives the ABC stacking.

Parameters
dr
coord
Returns
constexpr Tvec

Definition at line 466 of file crystalLattice.hpp.

Here is the call graph for this function:

◆ get_box_dim()

template<class Tvec>
constexpr Tvec shammath::LatticeFCC< Tvec >::get_box_dim ( Tscal dr,
u32 xcnt,
u32 ycnt,
u32 zcnt )
inlinestaticconstexpr

Get the box size for a FCC lattice of xcnt * ycnt * zcnt lattice cells this function will throw if the counts asked cannot make a periodic lattice.

Parameters
drthe particle spacing in the lattice
xcntnumber of particles per row along x
ycntnumber of rows along y (must be even)
zcntnumber of layers along z (must be a multiple of 3)
Returns
Tvec the dimensions of the periodic box

Definition at line 616 of file crystalLattice.hpp.

Here is the call graph for this function:

◆ get_box_index_bounds()

template<class Tvec>
constexpr std::pair< std::array< i32, dim >, std::array< i32, dim > > shammath::LatticeFCC< Tvec >::get_box_index_bounds ( Tscal dr,
Tvec box_min,
Tvec box_max )
inlinestaticconstexpr

Get the lattice integer coordinates bounds covering the given box (with a one cell margin on each side).

Definition at line 547 of file crystalLattice.hpp.

◆ get_ideal_fcc_box()

template<class Tvec>
std::tuple< Tvec, Tvec > shammath::LatticeFCC< Tvec >::get_ideal_fcc_box ( Tscal dr,
std::tuple< Tvec, Tvec > box )
inlinestatic

Get the smallest periodic FCC box containing the given box.

Definition at line 625 of file crystalLattice.hpp.

Here is the call graph for this function:

◆ get_periodic_box()

template<class Tvec>
constexpr CoordRange< Tvec > shammath::LatticeFCC< Tvec >::get_periodic_box ( Tscal dr,
std::array< i32, dim > coord_min,
std::array< i32, dim > coord_max )
inlinestaticconstexpr

Get the periodic box corresponding to integer lattice coordinates this function will throw if the coordinates asked cannot make a periodic lattice.

Parameters
drthe particle spacing in the lattice
coord_mininteger triplet for the minimal coordinates on the lattice
coord_maxinteger triplet for the maximal coordinates on the lattice
Returns
constexpr CoordRange<Tvec> the periodic box bounds

Definition at line 519 of file crystalLattice.hpp.

Here is the call graph for this function:

◆ nearest_periodic_box_indices()

template<class Tvec>
constexpr std::pair< std::array< i32, dim >, std::array< i32, dim > > shammath::LatticeFCC< Tvec >::nearest_periodic_box_indices ( std::array< i32, dim > coord_min,
std::array< i32, dim > coord_max )
inlinestaticconstexpr

get the nearest integer triplets bound that gives a periodic box (by only increasing the upper bound)

Parameters
coord_mininteger triplet for the minimal coordinates on the lattice
coord_maxinteger triplet for the maximal coordinates on the lattice
Returns
constexpr std::pair<std::array<i32, dim>, std::array<i32, dim>> the new bounds

Definition at line 581 of file crystalLattice.hpp.

Here is the call graph for this function:

◆ pmod()

template<class Tvec>
constexpr i32 shammath::LatticeFCC< Tvec >::pmod ( i32 a,
i32 b )
inlinestaticconstexprnoexcept

Positive modulo (C++ % keeps the sign of the dividend).

Definition at line 454 of file crystalLattice.hpp.

Member Data Documentation

◆ dim

template<class Tvec>
u32 shammath::LatticeFCC< Tvec >::dim = 3
staticconstexpr

Definition at line 443 of file crystalLattice.hpp.

◆ z_period

template<class Tvec>
i32 shammath::LatticeFCC< Tvec >::z_period = 3
staticconstexpr

Number of layers after which the stacking sequence repeats along z.

Definition at line 451 of file crystalLattice.hpp.


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