JDFTx  1.2.0
Phonon.h
1 /*-------------------------------------------------------------------
2 Copyright 2014 Ravishankar Sundararaman
3 
4 This file is part of JDFTx.
5 
6 JDFTx is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10 
11 JDFTx is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with JDFTx. If not, see <http://www.gnu.org/licenses/>.
18 -------------------------------------------------------------------*/
19 
20 #ifndef JDFTX_PHONON_PHONON_H
21 #define JDFTX_PHONON_PHONON_H
22 
23 #include <electronic/Everything.h>
24 #include <electronic/ColumnBundle.h>
25 #include <core/LatticeUtils.h>
26 
29 { int nBlocks, blockSize;
30  std::vector<int> colOffset;
31  std::vector<matrix> rots;
32 public:
33  void init(int nBlocks, int blockSize);
34  void set(int rowBlock, int colBlock, const matrix& rot);
35  void allReduce();
36 
37  matrix transform(const matrix& in) const;
38 };
39 
42 { class Phonon& phonon;
43  PhononEverything(class Phonon& phonon);
44 };
45 
47 class Phonon
48 {
49 public:
50  std::vector<std::pair<string,string> > input; //input file contents
51 
52  vector3<int> sup; //phonon supercell
53  double dr; //perturbation amplitude in Cartesian coordinates
54  double T; //temperature for free energy estimation
55  double Fcut; //fillings cutoff for optimizing number of bands
56 
57  Phonon();
58  void setup(bool printDefaults); //setup unit cell and basis modes for perturbations
59  void dump(); //main calculations (sequence of supercell calculations) as well as output
60 
61 private:
62  PhononEverything e; //data for original unit cell
63  PhononEverything eSupTemplate; //uninitialized version of eSup, with various flags later used to create eSup for each mode
64  std::shared_ptr<PhononEverything> eSup; //supercell data for current perturbation
65 
66  int nSpins, nSpinor; //number of explicit spins and spinor length
67  int nBandsOpt; //optimized number of bands, accounting for Fcut
68  int prodSup; //number of unit cells in supercell
69  std::vector< matrix3<> > symSupCart; //Cartesian symmetry rotation matrices for unperturbed supercell
70  std::vector< std::vector<BlockRotationMatrix> > stateRot; //Unitary rotation of states involved in gamma-point Hsub for each supercell symmetry operation
71 
72  //Basis for phonon modes (not reduced by symmetries):
73  struct Mode
74  { int sp, at;
75  vector3<> dir;
76  };
77  std::vector<Mode> modes;
78  std::vector<IonicGradient> dgrad;
79  std::vector< std::vector<matrix> > dHsub;
80 
81  //Minimal basis of perturbations for supercell calculations:
82  struct Perturbation : public Mode
83  { double weight;
84  };
85  std::vector<Perturbation> perturbations;
86 
87  //Run supercell calculation for specified perturbation
88  void processPerturbation(const Perturbation& pert);
89 
90  //set unperturbed state of supercell from unit cell
91  //optionally get the subspace Hamiltonian at supercell Gamma point (for all bands, not just those in nBandsOpt)
92  void setSupState(std::vector<matrix>* Hsub=0);
93 
94  //Mapping between unit cell and current supercell k-points (generated by processPerturbation and used by setSupState)
95  struct StateMapEntry : public Supercell::KmeshTransform //contain source k-point rotation here
96  { int qSup; //state index for supercell
97  int nqPrev; //number of previous unit cell k-points that point to this supercell
98  std::shared_ptr<class ColumnBundleTransform> transform; //wavefunction map
99  };
100  std::vector<StateMapEntry> stateMap; //map from unit cell k-points to supercell k-points
101 
102  //Utilities for mapping 3-dimensional and flattened cell indices:
103  vector3<int> getCell(int unit) const;
104  int getUnit(const vector3<int>& cell) const;
105 };
106 
107 #endif //JDFTX_PHONON_PHONON_H
Definition: LatticeUtils.h:58
Block rotation matrix: used for symmetrization of electronic states.
Definition: Phonon.h:28
General complex matrix.
Definition: matrix.h:58
matrix transform(const matrix &in) const
return rot * in * dagger(rot)
Calculate phonon dispersion, free energies and electron-phonon matrix elements.
Definition: Phonon.h:47
void init(int nBlocks, int blockSize)
initializes all blocks to zero
void allReduce()
collect over MPI
Add reference to class Phonon to Everything (for use with the parser)
Definition: Phonon.h:41
Definition: Everything.h:41