PSCF v1.5.0
Crystal Lattice

Unit cells, symmetries and symmetry-adapted basis. More...

Classes

class  Pscf::Basis< D >
 Symmetry-adapted Fourier basis for pseudo-spectral SCFT. More...
class  Pscf::BFieldComparison
 Comparator for fields in symmetry-adapted basis format. More...
struct  Pscf::BWave< D >
 Wave struct designed for use within Basis construction. More...
struct  Pscf::BWaveNormComp< D >
 Comparator for BWave objects, based on BWave::sqNorm. More...
struct  Pscf::BWaveStdComp< D >
 Comparator for BWave objects, based on BWave::indicesStd. More...
struct  Pscf::BWaveMinComp< D >
 Comparator for BWave objects, based on BWave::indicesMin. More...
class  Pscf::SpaceGroup< D >
 Crystallographic space group. More...
class  Pscf::SpaceSymmetry< D >
 A SpaceSymmetry represents a crystallographic space group symmetry. More...
class  Pscf::SymmetryGroup< Symmetry >
 Class template for a group of elements. More...
class  Pscf::UnitCell< D >
 Base template for UnitCell<D> classes, D=1, 2 or 3. More...
class  Pscf::UnitCell< 1 >
 1D crystal unit cell. More...
class  Pscf::UnitCell< 2 >
 2D crystal unit cell. More...
class  Pscf::UnitCell< 3 >
 3D crystal unit cell. More...
class  Pscf::UnitCellBase< D >
 Base class template for a crystallographic unit cell. More...

Functions

std::string Pscf::makeGroupFileName (int D, std::string groupName)
 Generates the file name from a group name.
template<int D>
int Pscf::convertFullParamIdToReduced (const int fullId, const typename UnitCell< D >::LatticeSystem lattice)
 Convert full lattice parameter index to a reduced index.
template<int D>
int Pscf::convertReducedParamIdToFull (const int reducedId, const typename UnitCell< D >::LatticeSystem lattice)
 Convert reduced lattice parameter index to a full index.
template<int D>
void Pscf::replicateUnitCell (IntVec< D > const &replicas, UnitCell< D > const &cellIn, UnitCell< D > &cellOut)
 Create a replicated UnitCell<D> (base template).
template<>
void Pscf::replicateUnitCell (IntVec< 1 > const &replicas, UnitCell< 1 > const &cellIn, UnitCell< 1 > &cellOut)
 Create a replicated UnitCell<1>.
template<>
void Pscf::replicateUnitCell (IntVec< 2 > const &replicas, UnitCell< 2 > const &cellIn, UnitCell< 2 > &cellOut)
 Create a replicated UnitCell<2>.
template<>
void Pscf::replicateUnitCell (IntVec< 3 > const &replicas, UnitCell< 3 > const &cellIn, UnitCell< 3 > &cellOut)
 Create a replicated UnitCell<3>.
template<int D>
IntVec< D > Pscf::shiftToMinimum (IntVec< D > const &v, IntVec< D > const &d, UnitCell< D > const &cell)
 Returns minimum magnitude image of DFT wavevector.
template<int D>
void Pscf::sortWaves (UnitCell< D > const &cell, IntVec< D > const &meshDimensions, std::vector< Sort::Item< double > > &items, GArray< Sort::Bunch > &bunches, double epsilon, bool isRealField)
 Sorted waves and identify bunches of equal magnitude.
template<int D>
std::ostream & Pscf::operator<< (std::ostream &out, SpaceGroup< D > const &g)
 Output stream inserter operator for a SpaceGroup<D>.
template<int D>
std::istream & Pscf::operator>> (std::istream &in, SpaceGroup< D > &g)
 Input stream extractor operator for a SpaceGroup<D>.
template<int D>
void Pscf::readGroup (std::string groupName, SpaceGroup< D > &group)
 Open and read a group file.
template<int D>
void Pscf::writeGroup (std::string filename, SpaceGroup< D > const &group)
 Open and write a group file.
template<int D>
bool Pscf::operator== (const SpaceSymmetry< D > &A, const SpaceSymmetry< D > &B)
 Are two SpaceSymmetry objects equivalent?
template<int D>
bool Pscf::operator!= (const SpaceSymmetry< D > &A, const SpaceSymmetry< D > &B)
 Are two SpaceSymmetry objects not equivalent?
template<int D>
SpaceSymmetry< D > Pscf::operator* (const SpaceSymmetry< D > &A, const SpaceSymmetry< D > &B)
 Return the product A*B of two symmetry objects.
template<int D>
IntVec< D > Pscf::operator* (const SpaceSymmetry< D > &S, const IntVec< D > &V)
 Return the IntVec<D> product S*V of a rotation matrix and an IntVec<D>.
template<int D>
IntVec< D > Pscf::operator* (const IntVec< D > &V, const SpaceSymmetry< D > &S)
 Return the IntVec<D> product V*S of an IntVec<D> and a rotation matrix.
template<int D>
std::ostream & Pscf::operator<< (std::ostream &out, const SpaceSymmetry< D > &A)
 Output stream inserter for a SpaceSymmetry<D>.
template<int D>
std::istream & Pscf::operator>> (std::istream &in, SpaceSymmetry< D > &A)
 Input stream extractor for a SpaceSymmetry<D>.
template<int D>
std::istream & Pscf::operator>> (std::istream &in, UnitCell< D > &cell)
 istream input extractor for a UnitCell<D>.
template<int D>
std::ostream & Pscf::operator<< (std::ostream &out, UnitCell< D > const &cell)
 ostream output inserter for a UnitCell<D>.
template<class Archive, int D>
void Pscf::serialize (Archive &ar, UnitCell< D > &cell, const unsigned int version)
 Serialize to/from an archive.
std::istream & Pscf::operator>> (std::istream &in, UnitCell< 1 >::LatticeSystem &lattice)
 istream extractor for a 1D UnitCell<1>::LatticeSystem.
std::ostream & Pscf::operator<< (std::ostream &out, UnitCell< 1 >::LatticeSystem lattice)
 ostream inserter for a 1D UnitCell<1>::LatticeSystem.
std::istream & Pscf::operator>> (std::istream &in, UnitCell< 2 >::LatticeSystem &lattice)
 istream extractor for a 2D UnitCell<2>::LatticeSystem.
std::istream & Pscf::operator>> (std::istream &in, UnitCell< 3 >::LatticeSystem &lattice)
 istream extractor for a 3D UnitCell<3>::LatticeSystem.
std::ostream & Pscf::operator<< (std::ostream &out, UnitCell< 3 >::LatticeSystem lattice)
 ostream inserter for an 3D UnitCell<3>::LatticeSystem.
template<int D>
void Pscf::readUnitCellHeader (std::istream &in, UnitCell< D > &cell)
 Read UnitCell<D> from a field file header (fortran PSCF format).
template<int D>
void Pscf::writeUnitCellHeader (std::ostream &out, UnitCell< D > const &cell)
 Write UnitCell<D> to a field file header (fortran PSCF format).

Detailed Description

Unit cells, symmetries and symmetry-adapted basis.

Function Documentation

◆ makeGroupFileName()

std::string Pscf::makeGroupFileName ( int D,
std::string groupName )

Generates the file name from a group name.

Parameters
Ddimensionality of space (D=1,2 or 3)
groupNamestandard name of space group

Definition at line 25 of file groupFile.cpp.

References makeGroupFileName(), and UTIL_THROW.

Referenced by makeGroupFileName(), and readGroup().

◆ convertFullParamIdToReduced()

template<int D>
int Pscf::convertFullParamIdToReduced ( const int fullId,
const typename UnitCell< D >::LatticeSystem lattice )

Convert full lattice parameter index to a reduced index.

Here, we define the "full" list of lattice parameters to be {a, b, c, alpha, beta, gamma}, and we define the "reduced" list of lattice parameters to be the list of independent parameters as defined by a particular lattice system (e.g., {a, c} for a tetragonal lattice). This function converts an index of a parameter in the full list, fullId, into the corresponding index in the reduced list, reducedId.

If fullId denotes a parameter that is able to vary but is not independent, then the index of the corresponding independent parameter in the reduced list is returned. For example, in a tetragonal lattice a == b, so a fullId of 1 would correspond to a reducedId of 0.

If fullId denotes a parameter that is rigid in a given lattice, then reducedId is set to -1. For example, all three angles are fixed at 90° in a tetragonal lattice, so a fullId value of 3, 4, or 5 would result in a reducedId of -1.

Parameters
fullIdthe value of fullId to convert
latticethe lattice system

References convertFullParamIdToReduced().

Referenced by Pscf::Rp::FilmFieldGenMask< D, CPT >::compute(), Pscf::Rp::FilmFieldGenMask< D, CUT >::compute(), convertFullParamIdToReduced(), convertReducedParamIdToFull(), Pscf::Rp::FilmFieldGenMask< D, CPT >::modifyStress(), Pscf::Rp::FilmFieldGenMask< D, CUT >::modifyStress(), Pscf::Rp::FilmFieldGenExt< D, CPT >::stress(), Pscf::Rp::FilmFieldGenExt< D, CUT >::stress(), Pscf::Rp::FilmFieldGenMask< D, CPT >::stress(), and Pscf::Rp::FilmFieldGenMask< D, CUT >::stress().

◆ convertReducedParamIdToFull()

template<int D>
int Pscf::convertReducedParamIdToFull ( const int reducedId,
const typename UnitCell< D >::LatticeSystem lattice )

Convert reduced lattice parameter index to a full index.

Here, we define the "full" list of lattice parameters to be {a, b, c, alpha, beta, gamma}, and we define the "reduced" list of lattice parameters to be the list of independent parameters as defined by a particular lattice system (e.g., {a, c} for a tetragonal lattice). This function converts an index of a parameter in the reduced list, reducedId, into the corresponding index in the full list, fullId.

Parameters
reducedIdthe value of reducedId to convert
latticethe lattice system

References convertFullParamIdToReduced(), and convertReducedParamIdToFull().

Referenced by convertReducedParamIdToFull().

◆ replicateUnitCell() [1/4]

template<int D>
void Pscf::replicateUnitCell ( IntVec< D > const & replicas,
UnitCell< D > const & cellIn,
UnitCell< D > & cellOut )

Create a replicated UnitCell<D> (base template).

Element i of the IntVec<D> parameter "replicas" contains the number of unit cell replicas along direction i, for i=0, ..., D-1.

Upon return, parameter "cellOut" is a UnitCell<D> with a lattice type and lattice parameters appropriate to represent a unit cell created by replicating "cellIn" the specified number of times in each direction. This function attempts to identify symmetries that are preserved by the choice of values in the "replicas" vector, and will generally try to use the highest symmetry unit cell type that is appropriate if more than one choice is possible. Thus, if a 3D cubic unit cell cellIn is replicated using a "replicas" vector with three equal elements, cellOut will be a cubic cell, whereas if a cubic cell replicated using a "replicas" vector in which all three elements are unequal, "cellOut" will be orthorhombic.

Some types of conversion of unit cells with high symmetry lattice types that would result in lower-symmetry lattice type have been prohibited if the appropriate conversion of lattice parameters has not yet been worked out. For example, for now, users may not create a triclinic unit cell by replicating a rhombohedral lattice using a replicas vector with unequal values for different elements. An Exception is thrown and an appropriate error message is written to standard output if a user attempts any such prohibited type of replication.

This base template is declared but not defined. Explicit specializations are defined for D=1, 2, and 3.

Parameters
replicasnumber of replicas in each direction (in)
cellInoriginal unit cell (in)
cellOutreplicated unit cell (out)

References replicateUnitCell().

◆ replicateUnitCell() [2/4]

template<>
void Pscf::replicateUnitCell ( IntVec< 1 > const & replicas,
UnitCell< 1 > const & cellIn,
UnitCell< 1 > & cellOut )

Create a replicated UnitCell<1>.

Parameters
replicasnumber of replicas in each direction (in)
cellInoriginal unit cell (in)
cellOutreplicated unit cell (out)

Definition at line 22 of file replicateUnitCell.cpp.

References Util::FSArray< Data, Capacity >::append(), Pscf::UnitCellBase< D >::nParameter(), Pscf::UnitCellBase< D >::parameters(), replicateUnitCell(), UTIL_CHECK, and UTIL_THROW.

Referenced by hasSymmetry(), replicateUnitCell(), replicateUnitCell(), replicateUnitCell(), replicateUnitCell(), replicateUnitCell(), and Pscf::Rp::FieldIo< D, T >::replicateUnitCell().

◆ replicateUnitCell() [3/4]

template<>
void Pscf::replicateUnitCell ( IntVec< 2 > const & replicas,
UnitCell< 2 > const & cellIn,
UnitCell< 2 > & cellOut )

Create a replicated UnitCell<2>.

Parameters
replicasnumber of replicas in each direction (in)
cellInoriginal unit cell (in)
cellOutreplicated unit cell (out)

Definition at line 51 of file replicateUnitCell.cpp.

References Util::FSArray< Data, Capacity >::append(), Pscf::UnitCellBase< D >::nParameter(), Pscf::UnitCellBase< D >::parameters(), replicateUnitCell(), UTIL_CHECK, and UTIL_THROW.

◆ replicateUnitCell() [4/4]

template<>
void Pscf::replicateUnitCell ( IntVec< 3 > const & replicas,
UnitCell< 3 > const & cellIn,
UnitCell< 3 > & cellOut )

Create a replicated UnitCell<3>.

Parameters
replicasnumber of replicas in each direction (in)
cellInoriginal unit cell (in)
cellOutreplicated unit cell (out)

Definition at line 132 of file replicateUnitCell.cpp.

References Util::FSArray< Data, Capacity >::append(), Pscf::UnitCellBase< D >::nParameter(), Pscf::UnitCellBase< D >::parameters(), replicateUnitCell(), UTIL_CHECK, and UTIL_THROW.

◆ shiftToMinimum()

template<int D>
IntVec< D > Pscf::shiftToMinimum ( IntVec< D > const & v,
IntVec< D > const & d,
UnitCell< D > const & cell )

Returns minimum magnitude image of DFT wavevector.

Parameters
vIntVec<D> containing integer indices of a wavevector
ddimensions of the discrete Fourier transform grid
cellUnitCell
Returns
integer indices of minimum image of v

◆ sortWaves()

template<int D>
void Pscf::sortWaves ( UnitCell< D > const & cell,
IntVec< D > const & meshDimensions,
std::vector< Sort::Item< double > > & items,
GArray< Sort::Bunch > & bunches,
double epsilon,
bool isRealField = true )

Sorted waves and identify bunches of equal magnitude.

Generate sorted waves and identify "bunches" of equal magnitude.

This function generates all wavevectors in the k-grid mesh associated with an r-grid mesh of specified dimensions, sorts them in order of increasing vector norm and identifies all "bunches" of wavevectors of equal norm. The function can generate wavevectors associated with the k-grid mesh used for either complex or real-valued fields, depending on the value of the bool parameter isRealField.

Upon return:

Element i of array "items" is a Sort::Item<double> object for which items[i].value is the squared norm of an associated wavevector and items[i].id is the rank of that wavevector within the k-grid mesh, while these items are now sorted in order of increasing wavevector norm.

Element i of array "bunches" is a Sort::Bunch objects for which elements of the items array with indices between bunches[i][0] and (bunches[i][1] - 1) have equal norms. Every bunch has one or more associated wavevectors, and every wavevector belongs to a unique bunch.

Parameters
cellcrystallographic unit cell (in)
meshDimensionsdimensions of real space mesh (in)
itemssorted array of items associated with wavevectors (out)
bunchesslices of items with equal squared wavenumbers (out)
epsilontolerance used to test for equality (in)
isRealFieldUse k-grid for DFT of a real field? (in)

Definition at line 25 of file sortWaves.cpp.

References Pscf::MeshIterator< D >::atEnd(), Pscf::MeshIterator< D >::begin(), Util::GArray< Data >::clear(), Pscf::Sort::findBunches(), Pscf::UnitCellBase< D >::ksq(), Pscf::MeshIterator< D >::position(), Pscf::MeshIterator< D >::rank(), Pscf::Sort::sort(), and sortWaves().

Referenced by sortWaves().

◆ operator<<() [1/5]

template<int D>
std::ostream & Pscf::operator<< ( std::ostream & out,
SpaceGroup< D > const & g )

Output stream inserter operator for a SpaceGroup<D>.

Parameters
outoutput stream
gspace group

Definition at line 109 of file SpaceGroup.h.

References Pscf::SymmetryGroup< Symmetry >::size().

◆ operator>>() [1/6]

template<int D>
std::istream & Pscf::operator>> ( std::istream & in,
SpaceGroup< D > & g )

Input stream extractor operator for a SpaceGroup<D>.

Parameters
ininput stream
gspace group

Definition at line 130 of file SpaceGroup.h.

References Pscf::SymmetryGroup< Symmetry >::add(), Pscf::SymmetryGroup< Symmetry >::clear(), Util::Label::Label(), and UTIL_CHECK.

◆ readGroup()

template<int D>
void Pscf::readGroup ( std::string groupName,
SpaceGroup< D > & group )

Open and read a group file.

Parameters
groupNamename of group, or group file (input)
groupspace group (output)

Definition at line 161 of file SpaceGroup.tpp.

References Pscf::SymmetryGroup< Symmetry >::clear(), Util::Log::file(), makeGroupFileName(), UTIL_CHECK, and UTIL_THROW.

◆ writeGroup()

template<int D>
void Pscf::writeGroup ( std::string filename,
SpaceGroup< D > const & group )

Open and write a group file.

Parameters
filenameoutput file name
groupspace group

Definition at line 200 of file SpaceGroup.tpp.

◆ operator==()

template<int D>
bool Pscf::operator== ( const SpaceSymmetry< D > & A,
const SpaceSymmetry< D > & B )

Are two SpaceSymmetry objects equivalent?

Parameters
Afirst symmetry
Bsecond symmetry
Returns
True if A == B, false otherwise

Definition at line 371 of file SpaceSymmetry.h.

◆ operator!=()

template<int D>
bool Pscf::operator!= ( const SpaceSymmetry< D > & A,
const SpaceSymmetry< D > & B )
inline

Are two SpaceSymmetry objects not equivalent?

Parameters
Afirst symmetry
Bsecond symmetry
Returns
True if A != B, false otherwise

Definition at line 319 of file SpaceSymmetry.h.

◆ operator*() [1/3]

template<int D>
SpaceSymmetry< D > Pscf::operator* ( const SpaceSymmetry< D > & A,
const SpaceSymmetry< D > & B )

Return the product A*B of two symmetry objects.

Parameters
Afirst symmetry
Bsecond symmetry
Returns
product A*B

Definition at line 392 of file SpaceSymmetry.h.

◆ operator*() [2/3]

template<int D>
IntVec< D > Pscf::operator* ( const SpaceSymmetry< D > & S,
const IntVec< D > & V )

Return the IntVec<D> product S*V of a rotation matrix and an IntVec<D>.

The product is defined to be the matrix product of the rotation matrix and the integer vector S.R * V.

Parameters
Ssymmetry operation
Vinteger vector
Returns
product S*V

Definition at line 425 of file SpaceSymmetry.h.

◆ operator*() [3/3]

template<int D>
IntVec< D > Pscf::operator* ( const IntVec< D > & V,
const SpaceSymmetry< D > & S )

Return the IntVec<D> product V*S of an IntVec<D> and a rotation matrix.

The product is defined to be the matrix product of the integer vector and the space group rotation matrix S.R * V.

Parameters
Vinteger vector
Ssymmetry operation
Returns
product V*S

Definition at line 442 of file SpaceSymmetry.h.

◆ operator<<() [2/5]

template<int D>
std::ostream & Pscf::operator<< ( std::ostream & out,
const SpaceSymmetry< D > & A )

Output stream inserter for a SpaceSymmetry<D>.

Parameters
outoutput stream
ASpaceSymmetry<D> object to be output
Returns
modified output stream

Definition at line 459 of file SpaceSymmetry.h.

◆ operator>>() [2/6]

template<int D>
std::istream & Pscf::operator>> ( std::istream & in,
SpaceSymmetry< D > & A )

Input stream extractor for a SpaceSymmetry<D>.

Parameters
ininput stream
ASpaceSymmetry<D> object to be input
Returns
modified input stream

Definition at line 479 of file SpaceSymmetry.h.

◆ operator>>() [3/6]

template<int D>
std::istream & Pscf::operator>> ( std::istream & in,
UnitCell< D > & cell )

istream input extractor for a UnitCell<D>.

If cell.lattice() is not Null, the lattice type read from stream must match the existing lattice type, or an Exception is thrown.

Parameters
ininput stream
cellUnitCell<D> to be read
Returns
modified input stream

Definition at line 549 of file UnitCell.h.

◆ operator<<() [3/5]

template<int D>
std::ostream & Pscf::operator<< ( std::ostream & out,
UnitCell< D > const & cell )

ostream output inserter for a UnitCell<D>.

Parameters
outoutput stream
cellUnitCell<D> to be written
Returns
modified output stream

Definition at line 563 of file UnitCell.h.

◆ serialize()

template<class Archive, int D>
void Pscf::serialize ( Archive & ar,
UnitCell< D > & cell,
const unsigned int version )

Serialize to/from an archive.

Parameters
arinput or output archive
cellUnitCell<D> object to be serialized
versionarchive version id

Definition at line 518 of file UnitCell.h.

◆ operator>>() [4/6]

std::istream & Pscf::operator>> ( std::istream & in,
UnitCell< 1 >::LatticeSystem & lattice )

istream extractor for a 1D UnitCell<1>::LatticeSystem.

Parameters
ininput stream
latticeUnitCell<1>::LatticeSystem to be read
Returns
modified input stream

Definition at line 110 of file UnitCell1.cpp.

References UTIL_THROW.

◆ operator<<() [4/5]

std::ostream & Pscf::operator<< ( std::ostream & out,
UnitCell< 1 >::LatticeSystem lattice )

ostream inserter for a 1D UnitCell<1>::LatticeSystem.

Parameters
outoutput stream
latticeUnitCell<1>::LatticeSystem to be written
Returns
modified output stream

Definition at line 127 of file UnitCell1.cpp.

References UTIL_THROW.

◆ operator>>() [5/6]

std::istream & Pscf::operator>> ( std::istream & in,
UnitCell< 2 >::LatticeSystem & lattice )

istream extractor for a 2D UnitCell<2>::LatticeSystem.

Parameters
ininput stream
latticeUnitCell<2>::LatticeSystem to be read
Returns
modified input stream

Definition at line 221 of file UnitCell2.cpp.

References UTIL_THROW.

◆ operator>>() [6/6]

std::istream & Pscf::operator>> ( std::istream & in,
UnitCell< 3 >::LatticeSystem & lattice )

istream extractor for a 3D UnitCell<3>::LatticeSystem.

Parameters
ininput stream
latticeUnitCell<3>::LatticeSystem to be read
Returns
modified input stream

Definition at line 391 of file UnitCell3.cpp.

References UTIL_THROW.

◆ operator<<() [5/5]

std::ostream & Pscf::operator<< ( std::ostream & out,
UnitCell< 3 >::LatticeSystem lattice )

ostream inserter for an 3D UnitCell<3>::LatticeSystem.

Parameters
outoutput stream
latticeUnitCell<3>::LatticeSystem to be written
Returns
modified output stream

Definition at line 426 of file UnitCell3.cpp.

References UTIL_THROW.

◆ readUnitCellHeader()

template<int D>
void Pscf::readUnitCellHeader ( std::istream & in,
UnitCell< D > & cell )

Read UnitCell<D> from a field file header (fortran PSCF format).

If the unit cell has a non-null lattice system on entry, the value read from file must match this existing value, or this function throws an exception. If the lattice system is null on entry, the lattice system value is read from file. In either case, unit cell parameters (dimensions and angles) are updated using values read from file.

Parameters
ininput stream
cellUnitCell<D> to be read

Definition at line 50 of file unitCellHeader.h.

Referenced by readFieldHeader().

◆ writeUnitCellHeader()

template<int D>
void Pscf::writeUnitCellHeader ( std::ostream & out,
UnitCell< D > const & cell )

Write UnitCell<D> to a field file header (fortran PSCF format).

Parameters
outoutput stream
cellUnitCell<D> to be written

Definition at line 80 of file unitCellHeader.h.

Referenced by writeFieldHeader().