PSCF v1.2
Basis.h
1#ifndef PRDC_BASIS_H
2#define PRDC_BASIS_H
3/*
4* PSCF - Polymer Self-Consistent Field Theory
5*
6* Copyright 2016 - 2022, The Regents of the University of Minnesota
7* Distributed under the terms of the GNU General Public License.
8*/
9
10#include <pscf/math/IntVec.h> // inline waveId
11#include <pscf/mesh/Mesh.h> // inline waveId
12#include <util/containers/DArray.h> // member
13#include <util/containers/GArray.h> // member
14
15namespace Pscf {
16namespace Prdc {
17
18 template <int D> class UnitCell;
19 template <int D> class SpaceGroup;
20
21 using namespace Util;
22
345 template <int D>
346 class Basis
347 {
348
349 public:
350
354 class Wave
355 {
356
357 public:
358
362 std::complex<double> coeff;
363
372
387
392
397
412
413 /*
414 * Default constructor.
415 */
416 Wave()
417 : coeff(0.0),
418 indicesDft(0),
419 indicesBz(0),
420 starId(0),
421 inverseId(-1),
422 implicit(false),
423 sqNorm(0.0)
424 {}
425
426 private:
427
431 double sqNorm;
432
433 friend class Basis<D>;
434
435 };
436
445 class Star
446 {
447
448 public:
449
453 int size;
454
459
466 int endId;
467
496
509
516
528
542 bool cancel;
543
544 /*
545 * Default constructor.
546 */
547 Star()
548 : size(0),
549 beginId(0),
550 endId(0),
551 invertFlag(0),
552 waveBz(0),
553 starId(0),
554 basisId(0),
555 cancel(false)
556 {}
557
558 };
559
560 // Public member functions of Basis<D>
561
565 Basis();
566
570 ~Basis();
571
584 void makeBasis(Mesh<D> const & mesh,
585 UnitCell<D> const & unitCell,
586 SpaceGroup<D> const & group);
587
613 void makeBasis(Mesh<D> const & mesh,
614 UnitCell<D> const & unitCell,
615 std::string groupName);
616
623 void outputWaves(std::ostream& out, bool outputAll = false) const;
624
631 void outputStars(std::ostream& out, bool outputAll = false) const;
632
636 bool isValid() const;
637
641 bool isInitialized() const;
642
643 // Accessors
644
648 int nWave() const;
649
653 int nBasisWave() const;
654
658 int nStar() const;
659
663 int nBasis() const;
664
670 Wave const & wave(int id) const;
671
679 Star const & star(int id) const;
680
686 Star const & basisFunction(int id) const;
687
699 int waveId(IntVec<D> vector) const;
700
701 private:
702
713 DArray<Wave> waves_;
714
720 GArray<Star> stars_;
721
730 DArray<int> waveIds_;
731
740 DArray<int> starIds_;
741
747 int nWave_;
748
752 int nBasisWave_;
753
757 int nStar_;
758
762 int nBasis_;
763
767 UnitCell<D> const * unitCellPtr_;
768
772 Mesh<D> const * meshPtr_;
773
777 bool isInitialized_;
778
782 void makeWaves();
783
787 void makeStars(const SpaceGroup<D>& group);
788
792 Mesh<D> const & mesh() const
793 { return *meshPtr_; }
794
798 UnitCell<D> const & unitCell() const
799 { return *unitCellPtr_; }
800
801 };
802
803 // Inline functions
804
805 template <int D>
806 inline int Basis<D>::nWave() const
807 { return nWave_; }
808
809 template <int D>
810 inline int Basis<D>::nBasisWave() const
811 { return nBasisWave_; }
812
813 template <int D>
814 inline int Basis<D>::nStar() const
815 { return nStar_; }
816
817 template <int D>
818 inline
819 typename Basis<D>::Wave const & Basis<D>::wave(int id) const
820 { return waves_[id]; }
821
822 template <int D>
823 inline
824 typename Basis<D>::Star const & Basis<D>::star(int id) const
825 { return stars_[id]; }
826
827 template <int D>
828 inline
829 typename Basis<D>::Star const & Basis<D>::basisFunction(int id) const
830 { return stars_[starIds_[id]]; }
831
832 template <int D>
833 int Basis<D>::waveId(IntVec<D> vector) const
834 {
835 meshPtr_->shift(vector);
836 int rank = mesh().rank(vector);
837 return waveIds_[rank];
838 }
839
840 template <int D>
841 inline bool Basis<D>::isInitialized() const
842 { return isInitialized_; }
843
844 #ifndef PRDC_BASIS_TPP
845 extern template class Basis<1>;
846 extern template class Basis<2>;
847 extern template class Basis<3>;
848 #endif
849
850} // namespace Prdc
851} // namespace Pscf
852#endif
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition IntVec.h:27
Description of a regular grid of points in a periodic domain.
A list of wavevectors that are related by space-group symmetries.
Definition Basis.h:446
int basisId
Index of basis function associated with this star.
Definition Basis.h:527
IntVec< D > waveBz
Integer indices indicesBz of a characteristic wave of this star.
Definition Basis.h:508
int invertFlag
Index for inversion symmetry of star.
Definition Basis.h:495
int size
Number of wavevectors in this star.
Definition Basis.h:453
int endId
Wave index of first wavevector of the next star.
Definition Basis.h:466
int beginId
Wave index of first wavevector in star.
Definition Basis.h:458
int starId
Index of this star in ordered array of all stars.
Definition Basis.h:515
bool cancel
Is this star cancelled, i.e., associated with a zero function?
Definition Basis.h:542
Wavevector used to construct a basis function.
Definition Basis.h:355
std::complex< double > coeff
Coefficient of wave within the associated star basis function.
Definition Basis.h:362
int starId
Index of the star that contains this wavevector.
Definition Basis.h:391
IntVec< D > indicesDft
Integer indices of wave, on a discrete Fourier transform mesh.
Definition Basis.h:371
int inverseId
Index of the wave that is the inverse of this wavevector.
Definition Basis.h:396
IntVec< D > indicesBz
Integer indices of wave, in first Brillouin zone.
Definition Basis.h:386
bool implicit
Is this wave represented implicitly in DFT of real field?
Definition Basis.h:411
Symmetry-adapted Fourier basis for pseudo-spectral scft.
Definition fieldIoUtil.h:21
Wave const & wave(int id) const
Get a specific Wave, access by integer index.
Definition Basis.h:819
int nBasis() const
Total number of nonzero symmetry-adapted basis functions.
Definition Basis.tpp:923
int waveId(IntVec< D > vector) const
Get the integer index of a wave, as required by wave(int id).
Definition Basis.h:833
int nStar() const
Total number of stars.
Definition Basis.h:814
Basis()
Default constructor.
Definition Basis.tpp:31
bool isInitialized() const
Returns true iff this basis is fully initialized.
Definition Basis.h:841
~Basis()
Destructor.
Definition Basis.tpp:49
void makeBasis(Mesh< D > const &mesh, UnitCell< D > const &unitCell, SpaceGroup< D > const &group)
Construct basis for a specific mesh and space group.
Definition Basis.tpp:69
void outputWaves(std::ostream &out, bool outputAll=false) const
Print a list of all waves to an output stream.
Definition Basis.tpp:928
int nWave() const
Total number of wavevectors.
Definition Basis.h:806
int nBasisWave() const
Total number of wavevectors in uncancelled stars.
Definition Basis.h:810
Star const & star(int id) const
Get a Star, accessed by integer star index.
Definition Basis.h:824
bool isValid() const
Returns true if valid, false otherwise.
Definition Basis.tpp:990
void outputStars(std::ostream &out, bool outputAll=false) const
Print a list of all stars to an output stream.
Definition Basis.tpp:957
Star const & basisFunction(int id) const
Get an uncancelled Star, accessed by basis function index.
Definition Basis.h:829
Crystallographic space group.
Definition FieldIoReal.h:23
Base template for UnitCell<D> classes, D=1, 2 or 3.
Definition rpg/System.h:34
Dynamically allocatable contiguous array template.
An automatically growable array, analogous to a std::vector.
Definition GArray.h:34
PSCF package top-level namespace.
Definition param_pc.dox:1
Utility classes for scientific computation.