PSCF v1.3
Pscf::Prdc::Cpu::WaveList< D > Class Template Reference

Class to calculate and store properties of wavevectors. More...

#include <WaveList.h>

Public Member Functions

 WaveList (bool isRealField=true)
 Constructor.
 ~WaveList ()
 Destructor.
void allocate (Mesh< D > const &m, UnitCell< D > const &c)
 Allocate memory and set association with a Mesh and UnitCell object.
void clearUnitCellData ()
 Clear all internal data that depends on lattice parameters.
void computeMinimumImages ()
 Compute minimum images of wavevectors.
void computeKSq ()
 Compute sq.
void computedKSq ()
 Compute derivatives of |k|^2 w/ respect to unit cell parameters.
DArray< IntVec< D > > const & minImages () const
 Get the array of minimum image vectors by const reference.
RField< D > const & kSq () const
 Get the kSq array on the device by const reference.
RField< D > const & dKSq (int i) const
 Get derivatives of kSq with respect to unit cell parameter i.
DArray< RField< D > > const & dKSq () const
 Get all derivatives of kSq with respect to unit cell parameters.
DArray< bool > const & implicitInverse () const
 Get the implicitInverse array by reference.
bool isAllocated () const
 Has memory been allocated for arrays?
bool hasMinImages () const
 Have minimum images been computed?
bool hasKSq () const
 Has the kSq array been computed?
bool hasdKSq () const
 Has the dKSq array been computed?
bool isRealField () const
 Does this WaveList correspond to real-valued fields?

Detailed Description

template<int D>
class Pscf::Prdc::Cpu::WaveList< D >

Class to calculate and store properties of wavevectors.

In particular, minimum images, square norms of wavevectors (kSq), and derivatives of the square norms of wavevectors with respect to the lattice parameters (dKSq) are calculated and stored by this class.

Any time the lattice parameters change the clearUnitCellData() method should be called, which will effectively reset the WaveList object so that the wavevector properties will need to be recalculated before being used.

This object calculates these wavevector properties for a mesh of grid points in k-space. If a calculation only requires real-valued fields, PSCF uses a reduced-size k-space mesh, as output by FFTW. However, a full-sized k-space mesh (the same size as the real-space mesh) is necessary when dealing with complex-valued fields. The k-space mesh used by a WaveList object is determined by the parameter isRealField, which is assigned in the constructor and cannot later be changed.

Definition at line 46 of file cpu/WaveList.h.

Constructor & Destructor Documentation

◆ WaveList()

template<int D>
Pscf::Prdc::Cuda::WaveList< D >::WaveList ( bool isRealField = true)

Constructor.

Parameters
isRealFieldWill this WaveList be used for real-valued fields?

Definition at line 29 of file cpu/WaveList.tpp.

References isRealField().

◆ ~WaveList()

template<int D>
Pscf::Prdc::Cuda::WaveList< D >::~WaveList ( )

Destructor.

Definition at line 43 of file cpu/WaveList.tpp.

Member Function Documentation

◆ allocate()

template<int D>
void Pscf::Prdc::Cuda::WaveList< D >::allocate ( Mesh< D > const & m,
UnitCell< D > const & c )

◆ clearUnitCellData()

template<int D>
void Pscf::Prdc::Cuda::WaveList< D >::clearUnitCellData ( )

Clear all internal data that depends on lattice parameters.

Sets hasKSq_ and hasdKSq_ to false. Sets hasMinImages_ to false only if the unit cell type has variable angles.

Definition at line 103 of file cpu/WaveList.tpp.

References Pscf::Prdc::hasVariableAngle().

Referenced by allocate().

◆ computeMinimumImages()

template<int D>
void Pscf::Prdc::Cuda::WaveList< D >::computeMinimumImages ( )

Compute minimum images of wavevectors.

(Also calculates kSq.)

The minimum images may change if a lattice angle in the unit cell is changed, so this method should be called whenever such changes occur.

In the process of computing the minimum images, the square norm |k|^2 for all wavevectors is also calculated and stored, so it is not necessary to call computeKSq after calling this method. computeKSq is provided to allow calculation of kSq without recalculating minimum images.

Definition at line 116 of file cpu/WaveList.tpp.

References Pscf::MeshIterator< D >::atEnd(), Pscf::MeshIterator< D >::begin(), Pscf::MeshIterator< D >::position(), Pscf::MeshIterator< D >::rank(), and UTIL_CHECK.

Referenced by computedKSq(), and computeKSq().

◆ computeKSq()

template<int D>
void Pscf::Prdc::Cuda::WaveList< D >::computeKSq ( )

Compute sq.

norm |k|^2 for all wavevectors, using existing min images.

Definition at line 143 of file cpu/WaveList.tpp.

References Pscf::MeshIterator< D >::atEnd(), Pscf::MeshIterator< D >::begin(), computeMinimumImages(), Pscf::MeshIterator< D >::rank(), and UTIL_CHECK.

◆ computedKSq()

template<int D>
void Pscf::Prdc::Cuda::WaveList< D >::computedKSq ( )

Compute derivatives of |k|^2 w/ respect to unit cell parameters.

Definition at line 175 of file cpu/WaveList.tpp.

References Pscf::MeshIterator< D >::atEnd(), Pscf::MeshIterator< D >::begin(), computeMinimumImages(), Pscf::MeshIterator< D >::rank(), and UTIL_CHECK.

◆ minImages()

template<int D>
DArray< IntVec< D > > const & Pscf::Prdc::Cpu::WaveList< D >::minImages ( ) const
inline

Get the array of minimum image vectors by const reference.

This function returns an array in which each element is an IntVec<D> containing the integer coordinates of the minimum image of one wavevector in the k-space mesh used for the DFT. If isRealField is true, this k-space mesh is smaller than the real-space mesh. Otherwise, it is the same size.

Definition at line 260 of file cpu/WaveList.h.

References UTIL_CHECK.

◆ kSq()

template<int D>
RField< D > const & Pscf::Prdc::Cuda::WaveList< D >::kSq ( ) const
inline

Get the kSq array on the device by const reference.

This function returns an array in which each element is the square magnitude |k|^2 of a wavevector k in the k-space mesh used for the DFT. If isRealField is true, this k-space mesh is smaller than the real-space mesh. Otherwise, it is the same size.

Definition at line 269 of file cpu/WaveList.h.

References UTIL_CHECK.

◆ dKSq() [1/2]

template<int D>
RField< D > const & Pscf::Prdc::Cuda::WaveList< D >::dKSq ( int i) const
inline

Get derivatives of kSq with respect to unit cell parameter i.

Each element contains the derivative of the square-wavevector with respect to unit cell parameter i, multiplied by a prefactor. The prefactor is 2.0 for waves that have an implicit inverse and 1.0 otherwise. The choice of prefactor is designed to simplify use of the array to compute stress.

Each element corresponds to one wavevector k in the k-space mesh used for the DFT. If isRealField is true, this k-space mesh is smaller than the real-space mesh. Otherwise, it is the same size. In the latter case, there are no implicit waves, so the prefactor is always 1.0.

Parameters
iindex of lattice parameter

Definition at line 278 of file cpu/WaveList.h.

References UTIL_CHECK.

◆ dKSq() [2/2]

template<int D>
DArray< RField< D > > const & Pscf::Prdc::Cpu::WaveList< D >::dKSq ( ) const
inline

Get all derivatives of kSq with respect to unit cell parameters.

Element i of the DArray is the RField<D> that can also be obtained from member function dKSq(int i).

Definition at line 287 of file cpu/WaveList.h.

References UTIL_CHECK.

◆ implicitInverse()

template<int D>
DeviceArray< bool > const & Pscf::Prdc::Cuda::WaveList< D >::implicitInverse ( ) const
inline

Get the implicitInverse array by reference.

This array is defined on a k-grid mesh, with a boolean value for each gridpoint. The boolean represents whether the inverse of the wave at the given gridpoint is an implicit wave. Implicit here is used to mean any wave that is outside the bounds of the k-grid.

This method will throw an error if isRealField == false, because there are no implicit inverses in such a case.

Definition at line 296 of file cpu/WaveList.h.

References UTIL_CHECK.

◆ isAllocated()

template<int D>
bool Pscf::Prdc::Cpu::WaveList< D >::isAllocated ( ) const
inline

Has memory been allocated for arrays?

Definition at line 167 of file cpu/WaveList.h.

◆ hasMinImages()

template<int D>
bool Pscf::Prdc::Cpu::WaveList< D >::hasMinImages ( ) const
inline

Have minimum images been computed?

Definition at line 173 of file cpu/WaveList.h.

◆ hasKSq()

template<int D>
bool Pscf::Prdc::Cpu::WaveList< D >::hasKSq ( ) const
inline

Has the kSq array been computed?

Definition at line 179 of file cpu/WaveList.h.

◆ hasdKSq()

template<int D>
bool Pscf::Prdc::Cpu::WaveList< D >::hasdKSq ( ) const
inline

Has the dKSq array been computed?

Definition at line 185 of file cpu/WaveList.h.

◆ isRealField()

template<int D>
bool Pscf::Prdc::Cpu::WaveList< D >::isRealField ( ) const
inline

Does this WaveList correspond to real-valued fields?

Definition at line 191 of file cpu/WaveList.h.

Referenced by WaveList().


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