Memosa-FVM  0.2
DensityOfStates< T > Class Template Reference

#include <DensityOfStates.h>

Collaboration diagram for DensityOfStates< T >:

Public Types

typedef Array< T > TArray
 
typedef Vector< T, 3 > VectorT3
 
typedef shared_ptr< TArrayTArrPtr
 
typedef vector< TArrPtrTArrList
 
typedef Array< int > IntArray
 
typedef shared_ptr< IntArrayIntArrayPtr
 
typedef vector< IntArrayPtrIntArrList
 
typedef Kspace< T > Tkspace
 
typedef kvol< T > Tkvol
 
typedef pmode< T > Tmode
 

Public Member Functions

 DensityOfStates (const Tkspace &kspace)
 
void binMode (const int mode, const int noBins, const T minw, const T maxw)
 
void binEntireKspace (const int noBins, const T minw, const T maxw)
 
void copyDOS (DensityOfStates &otherDOS)
 
void setDensity ()
 
const TkspacegetKspace ()
 
void saveNormDOS (const char *filename)
 
ArrayBasegetFreqMids ()
 
ArrayBasegetFreqBins ()
 
TArraygetFreqMidsT ()
 
TArraygetFreqBinsT ()
 
int findBin (const TArray &bounds, const T freq)
 
const int findBin (const T freq) const
 
IntArraygetKIndices (const int fBin)
 
IntArraygetMIndices (const int fBin)
 
IntArrListgetKptsList ()
 
IntArrListgetMList ()
 
TArraygetModeFractions (const int fBin)
 
sumOutgoing (const VectorT3 &n, const int fBin, const T Temp)
 
ArrayBasemakeDMMtransmission (DensityOfStates &otherDOS, const T Temp, const bool merge)
 
calcBinFlux (const T Temp, const int fBin, const T tau)
 
void mergeBins (DensityOfStates &otherDOS, const bool original)
 
void refineBins ()
 
ArrayBasemakeDMMreflection (ArrayBase *trans)
 

Private Member Functions

void addMode (const TArray &mBounds, const TArray &mMids, const IntArrList &mKlist, const int mode)
 
void setMids ()
 

Private Attributes

TArray _FreqMids
 
TArray _FreqBounds
 
TArray _Density
 
IntArrList _BinKpts
 
IntArrList _BinModes
 
TArrList _ModeFractions
 
const Tkspace_kspace
 

Detailed Description

template<class T>
class DensityOfStates< T >

Definition at line 12 of file DensityOfStates.h.

Member Typedef Documentation

template<class T>
typedef Array<int> DensityOfStates< T >::IntArray

Definition at line 20 of file DensityOfStates.h.

template<class T>
typedef shared_ptr<IntArray> DensityOfStates< T >::IntArrayPtr

Definition at line 21 of file DensityOfStates.h.

template<class T>
typedef vector<IntArrayPtr> DensityOfStates< T >::IntArrList

Definition at line 22 of file DensityOfStates.h.

template<class T>
typedef Array<T> DensityOfStates< T >::TArray

Definition at line 16 of file DensityOfStates.h.

template<class T>
typedef vector<TArrPtr> DensityOfStates< T >::TArrList

Definition at line 19 of file DensityOfStates.h.

template<class T>
typedef shared_ptr<TArray> DensityOfStates< T >::TArrPtr

Definition at line 18 of file DensityOfStates.h.

template<class T>
typedef Kspace<T> DensityOfStates< T >::Tkspace

Definition at line 23 of file DensityOfStates.h.

template<class T>
typedef kvol<T> DensityOfStates< T >::Tkvol

Definition at line 24 of file DensityOfStates.h.

template<class T>
typedef pmode<T> DensityOfStates< T >::Tmode

Definition at line 25 of file DensityOfStates.h.

template<class T>
typedef Vector<T,3> DensityOfStates< T >::VectorT3

Definition at line 17 of file DensityOfStates.h.

Constructor & Destructor Documentation

template<class T>
DensityOfStates< T >::DensityOfStates ( const Tkspace kspace)
inline

Definition at line 27 of file DensityOfStates.h.

27  :
28  _FreqMids(0),
29  _FreqBounds(0),
30  _Density(0),
31  _BinKpts(),
32  _BinModes(),
34  _kspace(kspace)
35  {}
IntArrList _BinModes
const Tkspace & _kspace
IntArrList _BinKpts
TArrList _ModeFractions

Member Function Documentation

template<class T>
void DensityOfStates< T >::addMode ( const TArray mBounds,
const TArray mMids,
const IntArrList mKlist,
const int  mode 
)
inlineprivate

Definition at line 567 of file DensityOfStates.h.

References DensityOfStates< T >::_BinKpts, DensityOfStates< T >::_BinModes, DensityOfStates< T >::_FreqBounds, DensityOfStates< T >::_FreqMids, DensityOfStates< T >::_ModeFractions, Array< T >::copyFrom(), Array< T >::getLength(), min(), Array< T >::resize(), DensityOfStates< T >::setMids(), and Array< T >::zero().

Referenced by DensityOfStates< T >::binMode().

568  {
569  if(_BinKpts.empty())
570  {
571  _FreqMids.resize(mMids.getLength());
572  _FreqMids.copyFrom(mMids);
573  _FreqBounds.resize(mBounds.getLength());
574  _FreqBounds.copyFrom(mBounds);
575  _BinKpts=mKlist;
576  _BinModes.resize(mMids.getLength());
577  _ModeFractions.resize(mMids.getLength());
578  for(int i=0;i<mMids.getLength();i++)
579  {
580  IntArray& Karray=*_BinKpts[i];
581  IntArrayPtr MarrayPtr=IntArrayPtr(new IntArray(Karray.getLength()));
582  TArrPtr FracArrPtr=TArrPtr(new TArray(Karray.getLength()));
583  *MarrayPtr=mode;
584  *FracArrPtr=1.;
585  _BinModes[i]=MarrayPtr;
586  _ModeFractions[i]=FracArrPtr;
587  }
588  }
589  else
590  {
592  old.copyFrom(_FreqBounds);
593  int newBinCount(0);
594 
595  int i(0), j(0);
596  T ceil=min(old[0], mBounds[0]);
597  T o,m;
598 
599  while(i<old.getLength() || j<mBounds.getLength())
600  {
601  if(i<old.getLength())
602  o=old[i];
603  else
604  o=mBounds[j]+1.;
605 
606  if(j<mBounds.getLength())
607  m=mBounds[j];
608  else
609  m=old[i]+1.;
610 
611  if(o==m)
612  {
613  if(o>ceil)
614  {
615  newBinCount++;
616  ceil=o;
617  }
618  i++;
619  j++;
620  }
621  else if( o>=ceil && o<m)
622  {
623  if(o>ceil)
624  {
625  ceil=o;
626  newBinCount++;
627  }
628  i++;
629  }
630  else if(m>=ceil && m<o)
631  {
632  if(m>ceil)
633  {
634  ceil=m;
635  newBinCount++;
636  }
637  j++;
638  }
639  }
640 
641  TArray newBounds(newBinCount+1);
642  ceil=min(old[0], mBounds[0]);
643  i=0;
644  j=0;
645  newBinCount=1;
646  newBounds[0]=ceil;
647 
648  while(i<old.getLength() || j<mBounds.getLength())
649  {
650  if(i<old.getLength())
651  o=old[i];
652  else
653  o=mBounds[j]+1.;
654 
655  if(j<mBounds.getLength())
656  m=mBounds[j];
657  else
658  m=old[i]+1.;
659 
660  if(o==m)
661  {
662  if(o>ceil)
663  {
664  newBounds[newBinCount]=o;
665  newBinCount++;
666  }
667  i++;
668  j++;
669  }
670  else if( o>=ceil && o<m)
671  {
672  if(o>ceil)
673  {
674  ceil=o;
675  newBounds[newBinCount]=o;
676  newBinCount++;
677  }
678  i++;
679  }
680  else if(m>=ceil && m<o)
681  {
682  if(m>ceil)
683  {
684  ceil=m;
685  newBounds[newBinCount]=m;
686  newBinCount++;
687  }
688  j++;
689  }
690  }
691 
692  _FreqBounds.resize(newBounds.getLength());
693  _FreqBounds.copyFrom(newBounds);
694  setMids();
695 
696  IntArray BinPop(_FreqMids.getLength());
697  BinPop.zero();
698  int searchStart(0);
699  for(int k=0; k<mBounds.getLength()-1;k++)
700  {
701  const T mTop=mBounds[k+1];
702  const T mBot=mBounds[k];
703  IntArray& klist=*mKlist[k];
704  const int plusKs=klist.getLength();
705 
706  for(int l=searchStart;l<_FreqBounds.getLength();l++)
707  {
708  if(_FreqBounds[l]>=mBot && _FreqBounds[l]<mTop)
709  BinPop[l]+=plusKs;
710  if(_FreqBounds[l]==mTop)
711  {
712  searchStart=l;
713  break;
714  }
715  }
716  }
717 
718  searchStart=0;
719  for(int k=0; k<old.getLength()-1;k++)
720  {
721  const T oTop=old[k+1];
722  const T oBot=old[k];
723  IntArray& klist=*_BinKpts[k];
724  const int plusKs=klist.getLength();
725 
726  for(int l=searchStart;l<_FreqBounds.getLength();l++)
727  {
728  if(_FreqBounds[l]>=oBot && _FreqBounds[l]<oTop)
729  BinPop[l]+=plusKs;
730  if(_FreqBounds[l]>=oTop)
731  {
732  searchStart=l;
733  break;
734  }
735  }
736  }
737 
738  IntArrList oldBinKpts=_BinKpts;
739  IntArrList oldBinModes=_BinModes;
740  TArrList oldModeFractions=_ModeFractions;
741  _BinKpts.resize(_FreqMids.getLength());
742  _BinModes.resize(_FreqMids.getLength());
744 
745  for(int fInd=0;fInd<_FreqMids.getLength();fInd++)
746  {
747  const int len=BinPop[fInd];
748  IntArrayPtr newKArray=IntArrayPtr(new IntArray(len));
749  IntArrayPtr newMArray=IntArrayPtr(new IntArray(len));
750  TArrPtr newFArray=TArrPtr(new TArray(len));
751  _BinKpts[fInd]=newKArray;
752  _BinModes[fInd]=newMArray;
753  _ModeFractions[fInd]=newFArray;
754  }
755 
756  searchStart=0;
757  BinPop.zero();
758  for(int k=0; k<mBounds.getLength()-1;k++)
759  {
760  const T mTop=mBounds[k+1];
761  const T mBot=mBounds[k];
762  const T dif=mTop-mBot;
763  IntArray& klist=*mKlist[k];
764 
765  for(int l=searchStart;l<_FreqBounds.getLength();l++)
766  {
767  if(_FreqBounds[l]>=mBot && _FreqBounds[l]<mTop)
768  {
769  const T masterDif=_FreqBounds[l+1]-_FreqBounds[l];
770  const T coeff=masterDif/dif;
771  IntArray& newKArray=*_BinKpts[l];
772  IntArray& newMArray=*_BinModes[l];
773  TArray& newFArray=*_ModeFractions[l];
774 
775  for(int addInd=0;addInd<klist.getLength();addInd++)
776  {
777  newKArray[BinPop[l]]=klist[addInd];
778  newMArray[BinPop[l]]=mode;
779  newFArray[BinPop[l]]=coeff;
780  BinPop[l]++;
781  }
782 
783  }
784  if(_FreqBounds[l]==mTop)
785  {
786  searchStart=l;
787  break;
788  }
789  }
790  }
791 
792  searchStart=0;
793  for(int k=0; k<old.getLength()-1;k++)
794  {
795  const T oTop=old[k+1];
796  const T oBot=old[k];
797  const T dif=oTop-oBot;
798  IntArray& klist=*oldBinKpts[k];
799  IntArray& mlist=*oldBinModes[k];
800  TArray& fraclist=*oldModeFractions[k];
801 
802  for(int l=searchStart;l<_FreqBounds.getLength();l++)
803  {
804  if(_FreqBounds[l]>=oBot && _FreqBounds[l]<oTop)
805  {
806  const T masterDif=_FreqBounds[l+1]-_FreqBounds[l];
807  const T coeff=masterDif/dif;
808  IntArray& newKArray=*_BinKpts[l];
809  IntArray& newMArray=*_BinModes[l];
810  TArray& newFArray=*_ModeFractions[l];
811 
812  for(int addInd=0;addInd<klist.getLength();addInd++)
813  {
814  newKArray[BinPop[l]]=klist[addInd];
815  newMArray[BinPop[l]]=mlist[addInd];
816  newFArray[BinPop[l]]=coeff*fraclist[addInd];
817  BinPop[l]++;
818  }
819  }
820  if(_FreqBounds[l]==oTop)
821  {
822  searchStart=l;
823  break;
824  }
825  }
826  }
827 
828  }
829  }
virtual void zero()
Definition: Array.h:281
Array< int > IntArray
vector< TArrPtr > TArrList
Array< T > TArray
void resize(const int newLength)
Definition: Array.h:56
shared_ptr< TArray > TArrPtr
IntArrList _BinModes
IntArrList _BinKpts
shared_ptr< IntArray > IntArrayPtr
TArrList _ModeFractions
double min(double x, double y)
Definition: Octree.cpp:23
virtual void copyFrom(const IContainer &oc)
Definition: Array.h:383
int getLength() const
Definition: Array.h:87
vector< IntArrayPtr > IntArrList
template<class T>
void DensityOfStates< T >::binEntireKspace ( const int  noBins,
const T  minw,
const T  maxw 
)
inline

Definition at line 91 of file DensityOfStates.h.

References DensityOfStates< T >::_BinKpts, DensityOfStates< T >::_BinModes, DensityOfStates< T >::_FreqBounds, DensityOfStates< T >::_FreqMids, DensityOfStates< T >::_kspace, Array< T >::copyFrom(), DensityOfStates< T >::findBin(), Kspace< T >::getkvol(), Kspace< T >::getlength(), kvol< T >::getmode(), kvol< T >::getmodenum(), pmode< T >::getomega(), Array< T >::resize(), and Array< T >::zero().

92  {
93  const T dwStar=1./T(noBins);
94  T Deltaw;
95  if(minw==0.)
96  Deltaw=maxw;
97  else
98  {
99  T ratio=minw/maxw;
100  Deltaw=(1-ratio)*maxw;
101  }
102  TArray modeBounds(noBins+1);
103  TArray modeMids(noBins);
104  IntArray BinKcount(noBins);
105  IntArray BinMcount(noBins);
106  BinKcount.zero();
107  BinMcount.zero();
108  IntArrList modeKpts;
109  IntArrList Mpts;
110 
111  for(int i=0;i<noBins+1;i++)
112  modeBounds[i]=floor(i*dwStar*Deltaw+minw);
113 
114  for(int i=0;i<noBins;i++)
115  modeMids[i]=(modeBounds[i]+modeBounds[i+1])/2.;
116 
117  const int klen=_kspace.getlength();
118 
119  for(int k=0;k<klen;k++)
120  {
121  Tkvol& kv=_kspace.getkvol(k);
122  const int modeNum=kv.getmodenum();
123  for(int m=0;m<modeNum;m++)
124  {
125  T omega=kv.getmode(m).getomega();
126  int bin=findBin(modeBounds, omega);
127  BinKcount[bin]++;
128  BinMcount[bin]++;
129  }
130  }
131 
132  for(int i=0;i<noBins;i++)
133  {
134  IntArrayPtr newArrPtr=IntArrayPtr(new IntArray(BinKcount[i]));
135  IntArrayPtr newArrPtr1=IntArrayPtr(new IntArray(BinKcount[i]));
136  newArrPtr->zero();
137  newArrPtr1->zero();
138  modeKpts.push_back(newArrPtr);
139  Mpts.push_back(newArrPtr1);
140  }
141 
142  BinKcount.zero();
143  BinMcount.zero();
144 
145  for(int k=0;k<klen;k++)
146  {
147  Tkvol& kv=_kspace.getkvol(k);
148  const int modeNum=kv.getmodenum();
149  for(int m=0;m<modeNum;m++)
150  {
151  T omega=kv.getmode(m).getomega();
152  int bin=findBin(modeBounds, omega);
153  IntArray& binArray=*modeKpts[bin];
154  IntArray& mbinArray=*Mpts[bin];
155  binArray[BinKcount[bin]]=k;
156  mbinArray[BinKcount[bin]]=m;
157  BinKcount[bin]++;
158  }
159  }
160 
161  _FreqMids.resize(noBins);
162  _FreqMids.copyFrom(modeMids);
163  _FreqBounds.resize(noBins+1);
164  _FreqBounds.copyFrom(modeBounds);
165  _BinKpts=modeKpts;
166  _BinModes=Mpts;
167 
168  }
Array< int > IntArray
int findBin(const TArray &bounds, const T freq)
Tkvol & getkvol(int n) const
Definition: Kspace.h:390
int getlength() const
Definition: Kspace.h:391
int getmodenum()
Definition: kvol.h:43
Array< T > TArray
void resize(const int newLength)
Definition: Array.h:56
IntArrList _BinModes
const Tkspace & _kspace
IntArrList _BinKpts
shared_ptr< IntArray > IntArrayPtr
virtual void copyFrom(const IContainer &oc)
Definition: Array.h:383
vector< IntArrayPtr > IntArrList
template<class T>
void DensityOfStates< T >::binMode ( const int  mode,
const int  noBins,
const T  minw,
const T  maxw 
)
inline

Definition at line 37 of file DensityOfStates.h.

References DensityOfStates< T >::_kspace, DensityOfStates< T >::addMode(), DensityOfStates< T >::findBin(), Kspace< T >::getkvol(), Kspace< T >::getlength(), kvol< T >::getmode(), pmode< T >::getomega(), and Array< T >::zero().

38  {
39  const T dwStar=1./T(noBins);
40  T Deltaw;
41  if(minw==0.)
42  Deltaw=maxw;
43  else
44  {
45  T ratio=minw/maxw;
46  Deltaw=(1-ratio)*maxw;
47  }
48  TArray modeBounds(noBins+1);
49  TArray modeMids(noBins);
50  IntArray BinKcount(noBins);
51  BinKcount.zero();
52  IntArrList modeKpts;
53 
54  for(int i=0;i<noBins+1;i++)
55  modeBounds[i]=floor(i*dwStar*Deltaw+minw);
56 
57  for(int i=0;i<noBins;i++)
58  modeMids[i]=(modeBounds[i]+modeBounds[i+1])/2.;
59 
60  const int klen=_kspace.getlength();
61 
62  for(int k=0;k<klen;k++)
63  {
64  T omega=_kspace.getkvol(k).getmode(mode).getomega();
65  int bin=findBin(modeBounds, omega);
66  BinKcount[bin]++;
67  }
68 
69  for(int i=0;i<noBins;i++)
70  {
71  IntArrayPtr newArrPtr=IntArrayPtr(new IntArray(BinKcount[i]));
72  newArrPtr->zero();
73  modeKpts.push_back(newArrPtr);
74  }
75 
76  BinKcount.zero();
77 
78  for(int k=0;k<klen;k++)
79  {
80  T omega=_kspace.getkvol(k).getmode(mode).getomega();
81  int bin=findBin(modeBounds, omega);
82  IntArray& binArray=*modeKpts[bin];
83  binArray[BinKcount[bin]]=k;
84  BinKcount[bin]++;
85  }
86 
87  addMode(modeBounds, modeMids, modeKpts, mode);
88 
89  }
Array< int > IntArray
int findBin(const TArray &bounds, const T freq)
Tkvol & getkvol(int n) const
Definition: Kspace.h:390
Tmode & getmode(int n) const
Definition: kvol.h:44
int getlength() const
Definition: Kspace.h:391
Array< T > TArray
const Tkspace & _kspace
void addMode(const TArray &mBounds, const TArray &mMids, const IntArrList &mKlist, const int mode)
T getomega()
Definition: pmode.h:63
shared_ptr< IntArray > IntArrayPtr
vector< IntArrayPtr > IntArrList
template<class T>
T DensityOfStates< T >::calcBinFlux ( const T  Temp,
const int  fBin,
const T  tau 
)
inline

Definition at line 327 of file DensityOfStates.h.

References DensityOfStates< T >::_kspace, pmode< T >::calce0(), kvol< T >::getdk3(), DensityOfStates< T >::getKIndices(), Kspace< T >::getkvol(), Array< T >::getLength(), DensityOfStates< T >::getMIndices(), kvol< T >::getmode(), and pmode< T >::getv().

328  {
329  T outSum(0.);
330  VectorT3 n;
331  n[0]=1.;
332  n[1]=0.;
333  n[2]=0.;
334 
335  if(fBin>=0)
336  {
337  const IntArray& Kpts=getKIndices(fBin);
338  const IntArray& Mpts=getMIndices(fBin);
339 
340  for(int i=0;i<Kpts.getLength();i++)
341  {
342  const int k=Kpts[i];
343  const int m=Mpts[i];
344  const VectorT3 vg=_kspace.getkvol(k).getmode(m).getv();
345  const T vdot=vg[0]*n[0]+vg[1]*n[1]+vg[2]*n[2];
346  const T e0=_kspace.getkvol(k).getmode(m).calce0(Temp);
347  if(vdot>0.)
348  {
349  const T dk3=_kspace.getkvol(k).getdk3();
350  outSum+=dk3*vdot*e0*tau;
351  }
352  }
353  }
354 
355  return outSum;
356  }
Array< int > IntArray
Tvec getv()
Definition: pmode.h:59
T calce0(T Tl)
Definition: pmode.h:88
Tkvol & getkvol(int n) const
Definition: Kspace.h:390
Tmode & getmode(int n) const
Definition: kvol.h:44
IntArray & getMIndices(const int fBin)
const Tkspace & _kspace
IntArray & getKIndices(const int fBin)
T getdk3()
Definition: kvol.h:42
template<class T>
void DensityOfStates< T >::copyDOS ( DensityOfStates< T > &  otherDOS)
inline

Definition at line 170 of file DensityOfStates.h.

References DensityOfStates< T >::_BinKpts, DensityOfStates< T >::_BinModes, DensityOfStates< T >::_FreqBounds, DensityOfStates< T >::_FreqMids, Array< T >::copyFrom(), DensityOfStates< T >::getFreqBinsT(), DensityOfStates< T >::getFreqMidsT(), DensityOfStates< T >::getKptsList(), Array< T >::getLength(), DensityOfStates< T >::getMList(), Array< T >::resize(), and DensityOfStates< T >::setDensity().

Referenced by DensityOfStates< T >::mergeBins().

171  {
172  _FreqMids.resize(otherDOS.getFreqMidsT().getLength());
173  _FreqMids.copyFrom(otherDOS.getFreqMidsT());
175  _FreqBounds.copyFrom(otherDOS.getFreqBinsT());
176  _BinKpts=otherDOS.getKptsList();
177  _BinModes=otherDOS.getMList();
178  setDensity();
179  }
void resize(const int newLength)
Definition: Array.h:56
IntArrList _BinModes
TArray & getFreqMidsT()
TArray & getFreqBinsT()
IntArrList _BinKpts
IntArrList & getKptsList()
virtual void copyFrom(const IContainer &oc)
Definition: Array.h:383
IntArrList & getMList()
int getLength() const
Definition: Array.h:87
template<class T>
int DensityOfStates< T >::findBin ( const TArray bounds,
const T  freq 
)
inline

Definition at line 223 of file DensityOfStates.h.

References Array< T >::getLength().

Referenced by DensityOfStates< T >::binEntireKspace(), DensityOfStates< T >::binMode(), DensityOfStates< T >::makeDMMtransmission(), and DensityOfStates< T >::mergeBins().

224  {
225  for(int i=0;i<bounds.getLength()-1;i++)
226  {
227  if(freq>bounds[i] && freq<=bounds[i+1])
228  return i;
229  }
230  throw CException("Frequency not in given discretization!");
231  }
template<class T>
const int DensityOfStates< T >::findBin ( const T  freq) const
inline

Definition at line 233 of file DensityOfStates.h.

References DensityOfStates< T >::_FreqBounds, and Array< T >::getLength().

234  {
235  for(int i=0;i<_FreqBounds.getLength()-1;i++)
236  {
237  if(freq>_FreqBounds[i] && freq<=_FreqBounds[i+1])
238  return i;
239  }
240  return -1;
241  }
int getLength() const
Definition: Array.h:87
template<class T>
ArrayBase* DensityOfStates< T >::getFreqBins ( )
inline

Definition at line 219 of file DensityOfStates.h.

References DensityOfStates< T >::_FreqBounds.

219 {return &_FreqBounds;}
template<class T>
TArray& DensityOfStates< T >::getFreqBinsT ( )
inline
template<class T>
ArrayBase* DensityOfStates< T >::getFreqMids ( )
inline

Definition at line 218 of file DensityOfStates.h.

References DensityOfStates< T >::_FreqMids.

218 {return &_FreqMids;}
template<class T>
IntArrList& DensityOfStates< T >::getKptsList ( )
inline

Definition at line 245 of file DensityOfStates.h.

References DensityOfStates< T >::_BinKpts.

Referenced by DensityOfStates< T >::copyDOS().

245 {return _BinKpts;}
IntArrList _BinKpts
template<class T>
const Tkspace& DensityOfStates< T >::getKspace ( )
inline

Definition at line 196 of file DensityOfStates.h.

References DensityOfStates< T >::_kspace.

Referenced by DensityOfStates< T >::mergeBins().

196 {return _kspace;}
const Tkspace & _kspace
template<class T>
IntArrList& DensityOfStates< T >::getMList ( )
inline

Definition at line 246 of file DensityOfStates.h.

References DensityOfStates< T >::_BinModes.

Referenced by DensityOfStates< T >::copyDOS().

246 {return _BinModes;}
IntArrList _BinModes
template<class T>
TArray& DensityOfStates< T >::getModeFractions ( const int  fBin)
inline

Definition at line 247 of file DensityOfStates.h.

References DensityOfStates< T >::_ModeFractions.

247 {return *_ModeFractions[fBin];}
TArrList _ModeFractions
template<class T>
ArrayBase* DensityOfStates< T >::makeDMMreflection ( ArrayBase trans)
inline

Definition at line 556 of file DensityOfStates.h.

References Array< T >::getLength().

557  {
558  TArray* Ttrans=dynamic_cast<TArray*>(trans);
559  TArray* refl=new TArray(Ttrans->getLength());
560  for(int i=0;i<Ttrans->getLength();i++)
561  (*refl)[i]=1.-(*Ttrans)[i];
562  return refl;
563  }
Array< T > TArray
template<class T>
ArrayBase* DensityOfStates< T >::makeDMMtransmission ( DensityOfStates< T > &  otherDOS,
const T  Temp,
const bool  merge 
)
inline

Definition at line 300 of file DensityOfStates.h.

References DensityOfStates< T >::_FreqMids, DensityOfStates< T >::findBin(), Array< T >::getLength(), DensityOfStates< T >::mergeBins(), and DensityOfStates< T >::sumOutgoing().

301  {
302  if(merge)
303  mergeBins(otherDOS, true);
304 
305  const int freqCount=_FreqMids.getLength();
306  TArray* trans=new TArray(freqCount);
307  VectorT3 n;
308 
309  n[0]=1.;
310  n[1]=0.;
311  n[2]=0.;
312 
313  for(int f0=0;f0<freqCount;f0++)
314  {
315  T w0=_FreqMids[f0];
316  const int f1=otherDOS.findBin(w0);
317  const T mat0sum=sumOutgoing(n,f0,Temp);
318  const T mat1sum=otherDOS.sumOutgoing(-n,f1,Temp);
319  if(mat1sum==0. && mat0sum==0.)
320  (*trans)[f0]=0.;
321  else
322  (*trans)[f0]=1./(1.+mat0sum/mat1sum);
323  }
324  return trans;
325  }
int findBin(const TArray &bounds, const T freq)
Array< T > TArray
T sumOutgoing(const VectorT3 &n, const int fBin, const T Temp)
void mergeBins(DensityOfStates &otherDOS, const bool original)
int getLength() const
Definition: Array.h:87
template<class T>
void DensityOfStates< T >::mergeBins ( DensityOfStates< T > &  otherDOS,
const bool  original 
)
inline

Definition at line 358 of file DensityOfStates.h.

References DensityOfStates< T >::_BinKpts, DensityOfStates< T >::_BinModes, DensityOfStates< T >::_FreqBounds, DensityOfStates< T >::_FreqMids, DensityOfStates< T >::_kspace, DensityOfStates< T >::_ModeFractions, DensityOfStates< T >::copyDOS(), Array< T >::copyFrom(), DensityOfStates< T >::findBin(), DensityOfStates< T >::getFreqBinsT(), DensityOfStates< T >::getKspace(), Kspace< T >::getkvol(), Array< T >::getLength(), Kspace< T >::getlength(), kvol< T >::getmode(), kvol< T >::getmodenum(), pmode< T >::getomega(), DensityOfStates< T >::mergeBins(), min(), Array< T >::resize(), DensityOfStates< T >::setDensity(), DensityOfStates< T >::setMids(), and Array< T >::zero().

Referenced by DensityOfStates< T >::makeDMMtransmission(), and DensityOfStates< T >::mergeBins().

359  {
360  DensityOfStates oldSelf(getKspace());
361  oldSelf.copyDOS(*this);
363  TArray& mBounds=otherDOS.getFreqBinsT();
364  old.copyFrom(_FreqBounds);
365  int newBinCount(0);
366 
367  int i(0), j(0);
368  T ceil=min(old[0], mBounds[0]);
369  T o,m;
370 
371  while(i<old.getLength() || j<mBounds.getLength())
372  {
373  if(i<old.getLength())
374  o=old[i];
375  else
376  o=mBounds[j]+1.;
377 
378  if(j<mBounds.getLength())
379  m=mBounds[j];
380  else
381  m=old[i]+1.;
382 
383  if(o==m)
384  {
385  if(o>ceil)
386  {
387  newBinCount++;
388  ceil=o;
389  }
390  i++;
391  j++;
392  }
393  else if( o>=ceil && o<m)
394  {
395  if(o>ceil)
396  {
397  ceil=o;
398  newBinCount++;
399  }
400  i++;
401  }
402  else if(m>=ceil && m<o)
403  {
404  if(m>ceil)
405  {
406  ceil=m;
407  newBinCount++;
408  }
409  j++;
410  }
411  }
412 
413  TArray newBounds(newBinCount+1);
414  ceil=min(old[0], mBounds[0]);
415  i=0;
416  j=0;
417  newBinCount=1;
418  newBounds[0]=ceil;
419 
420  while(i<old.getLength() || j<mBounds.getLength())
421  {
422  if(i<old.getLength())
423  o=old[i];
424  else
425  o=mBounds[j]+1.;
426 
427  if(j<mBounds.getLength())
428  m=mBounds[j];
429  else
430  m=old[i]+1.;
431 
432  if(o==m)
433  {
434  if(o>ceil)
435  {
436  newBounds[newBinCount]=o;
437  newBinCount++;
438  }
439  i++;
440  j++;
441  }
442  else if( o>=ceil && o<m)
443  {
444  if(o>ceil)
445  {
446  ceil=o;
447  newBounds[newBinCount]=o;
448  newBinCount++;
449  }
450  i++;
451  }
452  else if(m>=ceil && m<o)
453  {
454  if(m>ceil)
455  {
456  ceil=m;
457  newBounds[newBinCount]=m;
458  newBinCount++;
459  }
460  j++;
461  }
462  }
463 
464  _FreqBounds.resize(newBounds.getLength());
465  _FreqBounds.copyFrom(newBounds);
466  //refineBins();
467  setMids();
468 
469  IntArray BinPop(_FreqMids.getLength());
470  BinPop.zero();
471  //int searchStart(0);
472 
473  const int klen=_kspace.getlength();
474 
475  for(int k=0;k<klen;k++)
476  {
478  const int modenum=kvol.getmodenum();
479  for(int mode=0;mode<modenum;mode++)
480  {
481  T omega=_kspace.getkvol(k).getmode(mode).getomega();
482  int bin=findBin(_FreqBounds, omega);
483  BinPop[bin]++;
484  }
485  }
486 
487  _BinKpts.resize(_FreqMids.getLength());
488  _BinModes.resize(_FreqMids.getLength());
490 
491  for(int fInd=0;fInd<_FreqMids.getLength();fInd++)
492  {
493  const int len=BinPop[fInd];
494  IntArrayPtr newKArray=IntArrayPtr(new IntArray(len));
495  IntArrayPtr newMArray=IntArrayPtr(new IntArray(len));
496  TArrPtr newFArray=TArrPtr(new TArray(len));
497  _BinKpts[fInd]=newKArray;
498  _BinModes[fInd]=newMArray;
499  _ModeFractions[fInd]=newFArray;
500  }
501 
502  BinPop.zero();
503  for(int k=0;k<klen;k++)
504  {
505  Tkvol& kvol=_kspace.getkvol(k);
506  const int modenum=kvol.getmodenum();
507  for(int mode=0;mode<modenum;mode++)
508  {
509  T omega=_kspace.getkvol(k).getmode(mode).getomega();
510  int bin=findBin(_FreqBounds, omega);
511  IntArray& binKArray=*_BinKpts[bin];
512  IntArray& binMArray=*_BinModes[bin];
513  binKArray[BinPop[bin]]=k;
514  binMArray[BinPop[bin]]=mode;
515  BinPop[bin]++;
516  }
517  }
518 
519  setDensity();
520  if(original)
521  otherDOS.mergeBins(oldSelf,false);
522 
523  }
virtual void zero()
Definition: Array.h:281
Array< int > IntArray
int findBin(const TArray &bounds, const T freq)
Tkvol & getkvol(int n) const
Definition: Kspace.h:390
Tmode & getmode(int n) const
Definition: kvol.h:44
int getlength() const
Definition: Kspace.h:391
int getmodenum()
Definition: kvol.h:43
Array< T > TArray
const Tkspace & getKspace()
void resize(const int newLength)
Definition: Array.h:56
shared_ptr< TArray > TArrPtr
IntArrList _BinModes
const Tkspace & _kspace
TArray & getFreqBinsT()
IntArrList _BinKpts
T getomega()
Definition: pmode.h:63
shared_ptr< IntArray > IntArrayPtr
TArrList _ModeFractions
double min(double x, double y)
Definition: Octree.cpp:23
virtual void copyFrom(const IContainer &oc)
Definition: Array.h:383
Definition: kvol.h:14
void mergeBins(DensityOfStates &otherDOS, const bool original)
int getLength() const
Definition: Array.h:87
template<class T>
void DensityOfStates< T >::refineBins ( )
inline

Definition at line 525 of file DensityOfStates.h.

References DensityOfStates< T >::_FreqBounds, Array< T >::copyFrom(), Array< T >::getLength(), and Array< T >::resize().

526  {
527  int newBinCount(0);
528  const T eps=1.e-9;
530  old.copyFrom(_FreqBounds);
531  int i(0);
532 
533  while(i<_FreqBounds.getLength()-1)
534  {
535  T dif=1.-_FreqBounds[i+1]/_FreqBounds[i];
536  if(dif<eps)
537  {
538  old[newBinCount]=_FreqBounds[i];
539  newBinCount++;
540  i+=2;
541  }
542  else
543  {
544  old[newBinCount]=_FreqBounds[i];
545  newBinCount++;
546  i++;
547  }
548  }
549  old[newBinCount]=_FreqBounds[_FreqBounds.getLength()-1];
550 
551  _FreqBounds.resize(newBinCount+1);
552  for(int j=0;j<newBinCount+1;j++)
553  _FreqBounds[j]=old[j];
554  }
Array< T > TArray
void resize(const int newLength)
Definition: Array.h:56
int getLength() const
Definition: Array.h:87
template<class T>
void DensityOfStates< T >::saveNormDOS ( const char *  filename)
inline

Definition at line 198 of file DensityOfStates.h.

References DensityOfStates< T >::_Density, DensityOfStates< T >::_FreqBounds, DensityOfStates< T >::_FreqMids, and Array< T >::getLength().

199  {
200  const T wMax=_FreqBounds[_FreqBounds.getLength()-1];
201  const T wMin=_FreqBounds[0];
202  const T freqDif=wMax-wMin;
203  T maxDen=0.0;
204 
205  for(int i=0;i<_FreqMids.getLength();i++)
206  if(_Density[i]>maxDen)
207  maxDen=_Density[i];
208 
209  ofstream DOSfile;
210  DOSfile.open(filename);
211 
212  for(int i=0;i<_FreqMids.getLength();i++)
213  DOSfile<<(_FreqMids[i]-wMin)/freqDif<<" "<<_Density[i]/maxDen<<endl;
214 
215  DOSfile.close();
216  }
int getLength() const
Definition: Array.h:87
template<class T>
void DensityOfStates< T >::setDensity ( )
inline

Definition at line 181 of file DensityOfStates.h.

References DensityOfStates< T >::_BinKpts, DensityOfStates< T >::_Density, DensityOfStates< T >::_FreqMids, DensityOfStates< T >::_kspace, kvol< T >::getdk3(), Kspace< T >::getkvol(), Array< T >::getLength(), Array< T >::resize(), and Array< T >::zero().

Referenced by DensityOfStates< T >::copyDOS(), and DensityOfStates< T >::mergeBins().

182  {
184  _Density.zero();
185  for(int i=0;i<_Density.getLength();i++)
186  {
187  IntArray& Kpts=*_BinKpts[i];
188  for(int j=0;j<Kpts.getLength();j++)
189  {
190  const T dk3=_kspace.getkvol(Kpts[j]).getdk3();
191  _Density[i]+=dk3;
192  }
193  }
194  }
virtual void zero()
Definition: Array.h:281
Array< int > IntArray
Tkvol & getkvol(int n) const
Definition: Kspace.h:390
void resize(const int newLength)
Definition: Array.h:56
const Tkspace & _kspace
IntArrList _BinKpts
T getdk3()
Definition: kvol.h:42
int getLength() const
Definition: Array.h:87
template<class T>
void DensityOfStates< T >::setMids ( )
inlineprivate

Definition at line 831 of file DensityOfStates.h.

References DensityOfStates< T >::_FreqBounds, DensityOfStates< T >::_FreqMids, Array< T >::getLength(), and Array< T >::resize().

Referenced by DensityOfStates< T >::addMode(), and DensityOfStates< T >::mergeBins().

832  {
834  for(int i=0;i<_FreqBounds.getLength()-1;i++)
835  _FreqMids[i]=(_FreqBounds[i]+_FreqBounds[i+1])/2.;
836  }
void resize(const int newLength)
Definition: Array.h:56
int getLength() const
Definition: Array.h:87
template<class T>
T DensityOfStates< T >::sumOutgoing ( const VectorT3 n,
const int  fBin,
const T  Temp 
)
inline

Definition at line 249 of file DensityOfStates.h.

References DensityOfStates< T >::_kspace, pmode< T >::calce0(), kvol< T >::getdk3(), DensityOfStates< T >::getKIndices(), Kspace< T >::getkvol(), Array< T >::getLength(), DensityOfStates< T >::getMIndices(), kvol< T >::getmode(), and pmode< T >::getv().

Referenced by DensityOfStates< T >::makeDMMtransmission().

250  {
251  T outSum(0.);
252 
253  if(fBin>=0)
254  {
255  const IntArray& Kpts=getKIndices(fBin);
256  const IntArray& Mpts=getMIndices(fBin);
257  for(int i=0;i<Kpts.getLength();i++)
258  {
259  const int k=Kpts[i];
260  const int m=Mpts[i];
261  const VectorT3 vg=_kspace.getkvol(k).getmode(m).getv();
262  const T vdot=vg[0]*n[0]+vg[1]*n[1]+vg[2]*n[2];
263  if(vdot>0.)
264  {
265  const T dk3=_kspace.getkvol(k).getdk3();
266  outSum+=dk3*vdot*_kspace.getkvol(k).getmode(m).calce0(Temp);
267  }
268  }
269  }
270 
271  return outSum;
272  }
Array< int > IntArray
Tvec getv()
Definition: pmode.h:59
T calce0(T Tl)
Definition: pmode.h:88
Tkvol & getkvol(int n) const
Definition: Kspace.h:390
Tmode & getmode(int n) const
Definition: kvol.h:44
IntArray & getMIndices(const int fBin)
const Tkspace & _kspace
IntArray & getKIndices(const int fBin)
T getdk3()
Definition: kvol.h:42

Member Data Documentation

template<class T>
TArray DensityOfStates< T >::_Density
private
template<class T>
TArrList DensityOfStates< T >::_ModeFractions
private

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