PSCF v1.3
|
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 square norm |k|^2 for all wavevectors. | |
void | computedKSq () |
Compute derivatives of |k|^2 w/ respect to unit cell parameters. | |
DeviceArray< int > const & | minImages_d () const |
Get the array of minimum images on the device by reference. | |
HostDArray< IntVec< D > > const & | minImages_h () const |
Get minimum images as IntVec<D> objects on the host. | |
RField< D > const & | kSq () const |
Get the kSq array on the device by reference. | |
RField< D > const & | dKSq (int i) const |
Get derivatives of |k|^2 with respect to lattice parameter i. | |
DeviceArray< 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? |
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 cuFFT. 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 48 of file cuda/WaveList.h.
Pscf::Prdc::Cuda::WaveList< D >::WaveList | ( | bool | isRealField = true | ) |
Constructor.
isRealField | Will this WaveList be used for real-valued fields? |
References isRealField().
Pscf::Prdc::Cuda::WaveList< D >::~WaveList | ( | ) |
Destructor.
void Pscf::Prdc::Cuda::WaveList< D >::allocate | ( | Mesh< D > const & | m, |
UnitCell< D > const & | c ) |
void Pscf::Prdc::Cuda::WaveList< D >::clearUnitCellData | ( | ) |
Clear all internal data that depends on lattice parameters.
Sets hasKSq_ and hasdKSq_ to false, and sets hasMinImages_ to false if the crystall lattice type has variable angles.
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.
void Pscf::Prdc::Cuda::WaveList< D >::computeKSq | ( | ) |
Compute square norm |k|^2 for all wavevectors.
This function uses existing mininum images if they are valid, or recomputes them if necessary.
void Pscf::Prdc::Cuda::WaveList< D >::computedKSq | ( | ) |
Compute derivatives of |k|^2 w/ respect to unit cell parameters.
References minImages_d(), and minImages_h().
|
inline |
Get the array of minimum images on the device by reference.
The array has size kSize * D, where kSize is the number of grid points in the FFT k-space mesh. The array is unwrapped into a linear array in an index-by-index manner, in which the first kSize elements of the array contain the first index of each minimum image, and so on. If isRealField is true, kSize is smaller than the size of the real-space mesh. Otherwise, it is equal.
Definition at line 295 of file cuda/WaveList.h.
References UTIL_CHECK.
Referenced by computedKSq().
HostDArray< IntVec< D > > const & Pscf::Prdc::Cuda::WaveList< D >::minImages_h | ( | ) | const |
Get minimum images as IntVec<D> objects on the host.
The array has size kSize, and each element is an IntVec<D>. If isRealField is true, kSize is smaller than the size of the real-space mesh. Otherwise, it is equal.
Definition at line 691 of file cuda/WaveList.tpp.
References minImages_h(), and UTIL_CHECK.
Referenced by computedKSq(), and minImages_h().
RField< D > const & Pscf::Prdc::Cuda::WaveList< D >::kSq | ( | ) | const |
Get the kSq array on the device by reference.
This method returns an RField 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.
RField< D > const & Pscf::Prdc::Cuda::WaveList< D >::dKSq | ( | int | i | ) | const |
Get derivatives of |k|^2 with respect to lattice parameter i.
This method returns an RField in which each element is 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.
i | index of lattice parameter |
DeviceArray< bool > const & Pscf::Prdc::Cuda::WaveList< D >::implicitInverse | ( | ) | const |
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.
|
inline |
Has memory been allocated for arrays?
Definition at line 175 of file cuda/WaveList.h.
|
inline |
Have minimum images been computed?
Definition at line 181 of file cuda/WaveList.h.
|
inline |
Has the kSq array been computed?
Definition at line 187 of file cuda/WaveList.h.
|
inline |
Has the dKSq array been computed?
Definition at line 193 of file cuda/WaveList.h.
|
inline |
Does this WaveList correspond to real-valued fields?
Definition at line 199 of file cuda/WaveList.h.
Referenced by WaveList().