1 #ifndef _SCATTERINGKERNEL_H_
2 #define _SCATTERINGKERNEL_H_
11 template<
class T>
class Kspace;
33 {
_kspace.setScattKernel(*
this);}
35 void ReadType1(
const string& NamePhonon2,
const string& NamePhonon3,
const T tol)
38 const T hbar=6.582119e-16;
39 const T kb=8.617343e-5;
41 cout<<
"Reading type I collisions..."<<endl;
58 while(fp_in2==NULL && numAtt>0)
60 fp_in2=fopen(NamePhonon2.c_str(),
"rb");
62 cout<<
"Error reading 2 "<<numAtt<<endl;
67 while(fp_in3==NULL && numAtt>0)
69 fp_in3=fopen(NamePhonon3.c_str(),
"rb");
71 cout<<
"Error reading 3 "<<numAtt<<endl;
91 cout<<
"Counting I interactions..."<<endl;
93 for(
int i=0;i<rowLen;i++)
98 dum=fread(&row2,
sizeof(
int),1,fp_in2);
99 dum=fread(&nnz2,
sizeof(
int),1,fp_in2);
100 dum=fread(&row3,
sizeof(
int),1,fp_in3);
101 dum=fread(&nnz3,
sizeof(
int),1,fp_in3);
104 for(
int j=0;j<nnz2;j++)
106 dum=fread(&index2,
sizeof(
int),1,fp_in2);
107 dum=fread(&dkl,
sizeof(T),1,fp_in2);
108 dum=fread(&index3,
sizeof(
int),1,fp_in3);
109 dum=fread(&phi,
sizeof(T),1,fp_in3);
114 const T err=
fabs(w[row2]+w[index2]-w[index3])/w[row2];
117 const int m2=index2%6;
118 const int m3=index3%6;
139 cout<<row2<<
" "<<index2<<endl;
140 throw CException(
"I: negative value for phi!.");
145 cout<<row2<<
" "<<index2<<endl;
146 throw CException(
"I: negative value for dkl!.");
150 if(err<tol && zCnt!=1 && zCnt!=3 && dkl>0.)
169 cout<<
"Entering I values..."<<endl;
171 for(
int i=0;i<rowLen;i++)
176 dum=fread(&row2,
sizeof(
int),1,fp_in2);
177 dum=fread(&nnz2,
sizeof(
int),1,fp_in2);
178 dum=fread(&row3,
sizeof(
int),1,fp_in3);
179 dum=fread(&nnz3,
sizeof(
int),1,fp_in3);
182 for(
int j=0;j<nnz2;j++)
184 dum=fread(&index2,
sizeof(
int),1,fp_in2);
185 dum=fread(&dkl,
sizeof(T),1,fp_in2);
186 dum=fread(&index3,
sizeof(
int),1,fp_in3);
187 dum=fread(&phi,
sizeof(T),1,fp_in3);
192 const T err=
fabs(w[row2]+w[index2]-w[index3])/w[row2];
195 const int m2=index2%6;
196 const int m3=index3%6;
214 if(err<tol && zCnt!=1 && zCnt!=3 && dkl>0.)
232 void ReadType2(
const string& NamePhonon2,
const string& NamePhonon3,
const T tol)
235 cout<<
"Reading type II collisions..."<<endl;
236 const T hbar=6.582119e-16;
237 const T kb=8.617343e-5;
248 while(fp_in2==NULL && numAtt>0)
250 fp_in2=fopen(NamePhonon2.c_str(),
"rb");
252 cout<<
"Error reading 2 "<<numAtt<<endl;
257 while(fp_in3==NULL && numAtt>0)
259 fp_in3=fopen(NamePhonon3.c_str(),
"rb");
261 cout<<
"Error reading 3 "<<numAtt<<endl;
281 cout<<
"Counting II interactions..."<<endl;
283 for(
int i=0;i<rowLen;i++)
288 dum=fread(&row2,
sizeof(
int),1,fp_in2);
289 dum=fread(&nnz2,
sizeof(
int),1,fp_in2);
290 dum=fread(&row3,
sizeof(
int),1,fp_in3);
291 dum=fread(&nnz3,
sizeof(
int),1,fp_in3);
294 for(
int j=0;j<nnz2;j++)
296 dum=fread(&index2,
sizeof(
int),1,fp_in2);
297 dum=fread(&dkl,
sizeof(T),1,fp_in2);
298 dum=fread(&index3,
sizeof(
int),1,fp_in3);
299 dum=fread(&phi,
sizeof(T),1,fp_in3);
304 const T err=
fabs(w[row2]-w[index2]-w[index3])/w[index2];
307 const int m2=index2%6;
308 const int m3=index3%6;
321 cout<<row2<<
" "<<index2<<endl;
322 throw CException(
"II: negative value for phi!.");
327 cout<<row2<<
" "<<index2<<endl;
328 throw CException(
"II: negative value for dkl!.");
338 if(zCnt!=1 && zCnt!=3 && dkl>0. && err<tol)
356 cout<<
"Entering II values..."<<endl;
358 for(
int i=0;i<rowLen;i++)
363 dum=fread(&row2,
sizeof(
int),1,fp_in2);
364 dum=fread(&nnz2,
sizeof(
int),1,fp_in2);
365 dum=fread(&row3,
sizeof(
int),1,fp_in3);
366 dum=fread(&nnz3,
sizeof(
int),1,fp_in3);
369 for(
int j=0;j<nnz2;j++)
371 dum=fread(&index2,
sizeof(
int),1,fp_in2);
372 dum=fread(&dkl,
sizeof(T),1,fp_in2);
373 dum=fread(&index3,
sizeof(
int),1,fp_in3);
374 dum=fread(&phi,
sizeof(T),1,fp_in3);
379 const T err=
fabs(w[row2]-w[index2]-w[index3])/w[index2];
382 const int m2=index2%6;
383 const int m3=index3%6;
401 if(zCnt!=1 && zCnt!=3 && dkl>0. && err<tol)
440 for(
int i=0;i<Rows;i++)
442 for(
int pos=t1p2row[i];pos<t1p2row[i+1];pos++)
444 const int j2=t1p2col[pos];
445 const int j3=t1p3col[pos];
447 phi=phi/w[i]/w[j2]/w[j3];
452 for(
int i=0;i<Rows;i++)
454 for(
int pos=t2p2row[i];pos<t2p2row[i+1];pos++)
456 const int j2=t2p2col[pos];
457 const int j3=t2p3col[pos];
460 phi=phi/w[i]/w[j2]/w[j3];
469 const T hbarJoule=1.054571726e-34;
470 const T JouleToeV=6.24150974e18;
471 const T Acell=5.378395621705545e-20;
491 for(
int i=0;i<Rows;i++)
493 for(
int pos=t1p2row[i];pos<t1p2row[i+1];pos++)
495 const int j2=t1p2col[pos];
496 const int j3=t1p3col[pos];
497 const T dkl=t1dkl[pos];
498 const T phi=t1phi[pos];
499 const T n1=e[i]/w[i];
500 const T n2=e[j2]/w[j2];
501 const T n3=e[j3]/w[j3];
502 S[i]+=dkl*phi*(n1*(n3-n2)+n3*(n2+1));
507 for(
int i=0;i<Rows;i++)
509 for(
int pos=t2p2row[i];pos<t2p2row[i+1];pos++)
511 const int j2=t2p2col[pos];
512 const int j3=t2p3col[pos];
513 const T dkl=t2dkl[pos];
514 const T phi=t2phi[pos];
515 const T n1=e[i]/w[i];
516 const T n2=e[j2]/w[j2];
517 const T n3=e[j3]/w[j3];
518 S[i]+=dkl*phi*(n1*(n3-n2)+n3*(n2+1));
522 const T preFac=Acell/6.283185307/hbarJoule*JouleToeV;
523 for(
int i=0;i<Rows;i++)
531 const T hbarJoule=1.054571726e-34;
532 const T hbar=6.582119e-16;
534 const T Acell=5.378395621705545e-20;
535 const T cv=1e-9*1e-9;
542 _kspace.getEquilibriumArray(e,Tl);
561 for(
int i=0;i<Rows;i++)
563 for(
int pos=t1p2row[i];pos<t1p2row[i+1];pos++)
565 const int j2=t1p2col[pos];
566 const int j3=t1p3col[pos];
567 const T dkl=t1dkl[pos];
568 const T phi=t1phi[pos]*Acell;
569 const T n1=e[i]/hbar/w[i];
570 const T n2=e[j2]/hbar/w[j2];
571 const T n3=e[j3]/hbar/w[j3];
572 S[i]+=dkl*phi*((n1+1)*(n2+1)*n3-n1*n2*(n3+1));
577 for(
int i=0;i<Rows;i++)
579 for(
int pos=t2p2row[i];pos<t2p2row[i+1];pos++)
581 const int j2=t2p2col[pos];
582 const int j3=t2p3col[pos];
583 const T dkl=t2dkl[pos];
584 const T phi=t2phi[pos]*Acell;
585 const T n1=e[i]/w[i]/hbar;
586 const T n2=e[j2]/w[j2]/hbar;
587 const T n3=e[j3]/w[j3]/hbar;
588 S[i]+=0.5*dkl*phi*(n3*n2*(n1+1)-n1*(n2+1)*(n3+1));
592 const T preFac=1./2./3.141592653/pow(hbarJoule,2)*
_maxDkl*
_maxPhi*cv;
593 for(
int i=0;i<Rows;i++)
594 S[i]*=preFac*w[i]*hbar;
597 for(
int i=0;i<Rows;i++)
600 for(
int i=0;i<Rows;i++)
605 const int klen=
_kspace.getlength();
606 for(
int k=0;k<klen;k++)
611 for(
int m=0;m<modenum;m++)
619 cout<<
"New Temp: "<<temp<<endl;
626 const T hbarJoule=1.054571726e-34;
627 const T hbar=6.582119e-16;
628 const T Acell=5.378395621705545e-20;
629 const T kb=8.617343e-5;
638 const T Tlat(300.05);
639 const T Tl(
_kspace.calcLatTemp(c));
642 _kspace.getEquilibriumArray(e0,Tl);
659 for(
int i=0;i<Rows;i++)
661 for(
int pos=t1p2row[i];pos<t1p2row[i+1];pos++)
663 const int j2=t1p2col[pos];
664 const int j3=t1p3col[pos];
665 const T dkl=t1dkl[pos];
666 const T phi=t1phi[pos];
667 const T w3=w[i]+w[j2];
668 const T w1=w[j3]-w[j2];
669 const T n1=e[i]/w[i]/hbar;
670 const T n2=e[j2]/w[j2]/hbar;
671 const T n3=e[j3]/w[j3]/hbar;
672 const T n10=e0[i]/w[i]/hbar;
673 const T n20=e0[j2]/w[j2]/hbar;
674 const T n30=e0[j3]/w[j3]/hbar;
675 const T n012=1./(exp(hbar*w3/kb/Tl)-1.);
678 const T dn3=(n3-n30);
686 e032=hbar*w1/(exp(hbar*w1/kb/Tl)-1.);
695 const T nsum=Large*(-dn1*dn2/Large+dn3/Large+dn1*dn3/Large
696 +dn2*dn3/Large-dn2*n10/Large+dn3*n10/Large-dn1*n20/Large
697 +dn3*n20/Large+dn1*n30/Large+dn2*n30/Large);
715 for(
int i=0;i<Rows;i++)
717 for(
int pos=t2p2row[i];pos<t2p2row[i+1];pos++)
719 const int j2=t2p2col[pos];
720 const int j3=t2p3col[pos];
721 const T dkl=t2dkl[pos];
722 const T phi=t2phi[pos];
723 const T w3=w[i]+w[j2];
724 const T w1=w[j3]-w[j2];
725 const T n1=e[i]/w[i]/hbar;
726 const T n2=e[j2]/w[j2]/hbar;
727 const T n3=e[j3]/w[j3]/hbar;
728 const T n10=e0[i]/w[i]/hbar;
729 const T n20=e0[j2]/w[j2]/hbar;
730 const T n30=e0[j3]/w[j3]/hbar;
731 const T n012=1./(exp(hbar*w3/kb/Tl)-1.);
734 const T dn3=(n3-n30);
741 e032=hbar*w1/(exp(hbar*w1/kb/Tl)-1.);
752 const T nsum=Large*(-dn1/Large-dn1*dn2/Large-dn1*dn3/Large
753 +dn2*dn3/Large-dn2*n10/Large-dn3*n10/Large
754 -dn1*n20/Large+dn3*n20/Large-dn1*n30/Large
757 S[i]+=0.5*dkl*phi*nsum;
763 const int klen=
_kspace.getlength();
764 for(
int i=0;i<Rows;i++)
766 S[i]*=(preFac*w[i]*hbar);
775 const int cStart(
_kspace.getGlobalIndex(c,0));
778 for(
int k=0;k<klen;k++)
783 for(
int m=0;m<modenum;m++)
785 defect+=((S[cnt]/maxS)*(dk3/DK3));
787 const T tau=mode.
gettau();
788 cOt+=mode.
calce0(Tl)*(dk3/DK3);
807 for(
int k=0;k<klen;k++)
812 for(
int m=0;m<modenum;m++)
815 const T tau=mode.
gettau();
817 const T e0(mode.
calce0(Tl));
819 S[cnt]=d*(S[cnt]/d-e0/cOt);
820 defect+=((S[cnt]/maxS)*(dk3/DK3));
838 const T hbarJoule=1.054571726e-34;
839 const T hbar=6.582119e-16;
840 const T Acell=5.378395621705545e-20;
841 const T kb=8.617343e-5;
856 const T Tl(
_kspace.calcLatTemp(c));
859 _kspace.getEquilibriumArray(e0,Tl);
871 for(
int i=0;i<Rows;i++)
873 const int k1=floor(i/6);
874 const T dk31=
_kspace.getkvol(k1).getdk3();
875 for(
int pos=t1p2row[i];pos<t1p2row[i+1];pos++)
877 const int j2=t1p2col[pos];
878 const int k2=floor(j2/6);
879 const T dk32=
_kspace.getkvol(k2).getdk3();
880 const int j3=t1p3col[pos];
881 const int k3=floor(j3/6);
882 const T dk33=
_kspace.getkvol(k3).getdk3();
883 const T dkl=t1dkl[pos];
884 const T phi=t1phi[pos];
885 const T w3=w[i]+w[j2];
887 const T n1=e[i]/w[i]/hbar;
888 const T n2=e[j2]/w[j2]/hbar;
889 const T n3=e[j3]/w[j3]/hbar;
890 const T n10=e0[i]/w[i]/hbar;
891 const T n20=e0[j2]/w[j2]/hbar;
892 const T n30=e0[j3]/w[j3]/hbar;
896 const T dn3=(n3-n30);
907 const T nsum=(-dn1*dn2+dn3+dn1*dn3
908 +dn2*dn3-dn2*n10+dn3*n10-dn1*n20
909 +dn3*n20+dn1*n30+dn2*n30);
915 Sl[i]+=dkl*phi*nsum*w[i];
916 Sl[j2]+=dkl*phi*nsum*w[j2]*dk31/dk32;
917 Sl[j3]-=dkl*phi*nsum*w3*dk31/dk33;
924 const T preFac=Acell/16./3.141592653*hbarJoule*
_maxPhi*hbar*
_maxDkl;
925 const int klen=
_kspace.getlength();
926 for(
int i=0;i<Rows;i++)
934 long double defect(0);
937 const int cStart(
_kspace.getGlobalIndex(c,0));
940 for(
int k=0;k<klen;k++)
945 for(
int m=0;m<modenum;m++)
947 defect+=((Sl[cnt]/maxS)*(dk3/DK3));
952 cOt+=mode.
calce0(Tl)*(dk3/DK3);
973 for(
int k=0;k<klen;k++)
978 for(
int m=0;m<modenum;m++)
986 defect+=((Sl[cnt]/maxS)*(dk3/DK3));
995 for(
int i=0;i<Rows;i++)
1006 const T hbarJoule=1.054571726e-34;
1007 const T hbar=6.582119e-16;
1008 const T Acell=5.378395621705545e-20;
1009 const T kb=8.617343e-5;
1024 const T Tl(
_kspace.calcLatTemp(c));
1027 _kspace.getEquilibriumArray(e0,Tl);
1046 for(
int i=0;i<Rows;i++)
1050 for(
int pos=t1p2row[i];pos<t1p2row[i+1];pos++)
1052 const int j2=t1p2col[pos];
1055 const int j3=t1p3col[pos];
1058 const T dkl=t1dkl[pos];
1059 const T phi=t1phi[pos];
1065 const T n10=1./(exp(hbar*w[i]/kb/300)-1.);
1066 const T n20=1./(exp(hbar*w[j2]/kb/300)-1.);
1067 const T n30=1./(exp(hbar*w[j3]/kb/300)-1.);
1076 const T nsum=(-dn1*dn2+dn3+dn1*dn3
1077 +dn2*dn3-dn2*n10+dn3*n10-dn1*n20
1078 +dn3*n20+dn1*n30+dn2*n30);
1082 const T ds1=-dn2+dn3-n20+n30;
1087 Sl[i]+=dkl*phi*nsum;
1092 dSl[i]+=dkl*phi*ds1;
1103 for(
int i=0;i<Rows;i++)
1107 for(
int pos=t2p2row[i];pos<t2p2row[i+1];pos++)
1109 const int j2=t2p2col[pos];
1112 const int j3=t2p3col[pos];
1115 const T dkl=t2dkl[pos];
1116 const T phi=t2phi[pos];
1123 const T n10=1./(exp(hbar*w[i]/kb/300)-1.);
1124 const T n20=1./(exp(hbar*w[j2]/kb/300)-1.);
1125 const T n30=1./(exp(hbar*w[j3]/kb/300)-1.);
1133 const T nsum=(-dn1-dn1*dn2-dn1*dn3
1134 +dn2*dn3-dn2*n10-dn3*n10
1135 -dn1*n20+dn3*n20-dn1*n30
1138 const T ds1=-(1+dn2+dn3+n20+n30);
1148 Sl[i]+=0.5*dkl*phi*nsum;
1150 dSl[i]+=0.5*dkl*phi*ds1;
1162 const int klen=
_kspace.getlength();
1163 for(
int i=0;i<Rows;i++)
1171 long double defect(0);
1174 const int cStart(
_kspace.getGlobalIndex(c,0));
1177 for(
int k=0;k<klen;k++)
1182 for(
int m=0;m<modenum;m++)
1184 defect+=((Sl[cnt]/maxS)*(dk3/DK3));
1188 const T tau=mode.
gettau();
1189 cOt+=mode.
calce0(Tl)*(dk3/DK3);
1191 eq+=(e0[ind]-e[ind])/tau*(dk3/DK3);
1209 for(
int k=0;k<klen;k++)
1214 for(
int m=0;m<modenum;m++)
1222 defect+=((Sl[cnt]/maxS)*(dk3/DK3));
1232 for(
int i=0;i<Rows;i++)
1243 const T hbarJoule=1.054571726e-34;
1244 const T hbar=6.582119e-16;
1245 const T Acell=5.378395621705545e-20;
1246 const T kb=8.617343e-5;
1261 const T Tl(
_kspace.calcLatTemp(c));
1264 _kspace.getEquilibriumArray(e0,Tl);
1279 for(
int i=0;i<Rows;i++)
1281 const int k1=floor(i/6);
1282 const T dk31=
_kspace.getkvol(k1).getdk3();
1283 for(
int pos=t2p2row[i];pos<t2p2row[i+1];pos++)
1285 const int j2=t2p2col[pos];
1286 const int k2=floor(j2/6);
1287 const T dk32=
_kspace.getkvol(k2).getdk3();
1288 const int j3=t2p3col[pos];
1289 const int k3=floor(j3/6);
1290 const T dk33=
_kspace.getkvol(k3).getdk3();
1291 const T dkl=t2dkl[pos];
1292 const T phi=t2phi[pos];
1293 const T w3=w[i]-w[j2];
1296 const T n1=e[i]/w[i]/hbar;
1297 const T n2=e[j2]/w[j2]/hbar;
1298 const T n3=e[j3]/w[j3]/hbar;
1299 const T n10=e0[i]/w[i]/hbar;
1300 const T n20=e0[j2]/w[j2]/hbar;
1301 const T n30=e0[j3]/w[j3]/hbar;
1306 const T dn3=(n3-n30);
1317 const T nsum=(-dn1-dn1*dn2-dn1*dn3
1318 +dn2*dn3-dn2*n10-dn3*n10
1319 -dn1*n20+dn3*n20-dn1*n30
1322 const T ds1=-(1+dn2+dn3-n20-n30);
1323 const T ds2=-dn1+dn3-n10+n30;
1324 const T ds3=-dn1+dn2-n10+n20;
1333 Sl[i]+=0.5*dkl*phi*nsum*w[i];
1334 dSl[i]+=0.5*dkl*phi*ds1*w[i];
1339 Sl[j2]-=0.5*dkl*phi*nsum*w[j2]*dk31/dk32;
1340 dSl[j2]-=0.5*dkl*phi*ds2*w[j2]*dk31/dk32;
1342 Sl[j3]-=0.5*dkl*phi*nsum*w3*dk31/dk33;
1343 dSl[j3]-=0.5*dkl*phi*ds3*w3*dk31/dk33;
1357 const T preFac=Acell/16./3.141592653*hbarJoule*
_maxPhi*hbar*
_maxDkl;
1358 const int klen=
_kspace.getlength();
1359 for(
int i=0;i<Rows;i++)
1367 long double defect(0);
1370 const int cStart(
_kspace.getGlobalIndex(c,0));
1373 for(
int k=0;k<klen;k++)
1378 for(
int m=0;m<modenum;m++)
1380 defect+=((Sl[cnt]/maxS)*(dk3/DK3));
1385 cOt+=mode.
calce0(Tl)*(dk3/DK3);
1405 for(
int k=0;k<klen;k++)
1410 for(
int m=0;m<modenum;m++)
1418 defect+=((Sl[cnt]/maxS)*(dk3/DK3));
1427 for(
int i=0;i<Rows;i++)
1438 const T hbarJoule=1.054560652926899e-34;
1439 const T hbar=6.582119e-16;
1441 const T Acell=5.378395621705545e-20;
1442 const T kb=8.617343e-5;
1467 const int Rows=S.getLength();
1481 const T preFac=Acell/16.*hbarJoule*
_maxPhi*
_maxDkl/3.14159265358979323846264;
1483 for(
int i=0;i<Rows;i++)
1484 e[i]=hbar*w[i]/(exp(hbar*w[i]/kb/Tl)-1);
1486 e[100]=hbar*w[100]/(exp(hbar*w[100]/kb/(Tl+1.))-1);
1488 for(
int it=0;it<totIts;it++)
1494 for(
int i=0;i<Rows;i++)
1496 for(
int pos=t1p2row[i];pos<t1p2row[i+1];pos++)
1498 const int j2=t1p2col[pos];
1499 const int j3=t1p3col[pos];
1500 const T dkl=t1dkl[pos];
1501 const T phi=t1phi[pos];
1503 const T n1=e[i]/hbar/w[i];
1504 const T n2=e[j2]/hbar/w[j2];
1505 const T n3=e[j3]/hbar/w[j3];
1506 const T n10=1./(exp(hbar*w[i]/kb/300.)-1);
1507 const T n20=1./(exp(hbar*w[j2]/kb/300.)-1);
1508 const T n30=1./(exp(hbar*w[j3]/kb/300.)-1);
1513 const T nsum=(-dn1*dn2+dn3+dn1*dn3
1514 +dn2*dn3-dn2*n10+dn3*n10-dn1*n20
1515 +dn3*n20+dn1*n30+dn2*n30);
1518 t[i]+=dkl*phi*(n20-n30);
1519 gam1[i]+=dkl*phi*nsum;
1522 for(
int pos=t2p2row[i];pos<t2p2row[i+1];pos++)
1524 const int j2=t2p2col[pos];
1525 const int k2=floor(j2/6);
1527 const int j3=t2p3col[pos];
1528 const int k3=floor(j3/6);
1530 const T dkl=t2dkl[pos];
1531 const T phi=t2phi[pos];
1533 const T n1=e[i]/w[i]/hbar;
1534 const T n2=e[j2]/w[j2]/hbar;
1535 const T n3=e[j3]/w[j3]/hbar;
1536 const T n10=1./(exp(hbar*w[i]/kb/300.)-1);
1537 const T n20=1./(exp(hbar*w[j2]/kb/300.)-1);
1538 const T n30=1./(exp(hbar*w[j3]/kb/300.)-1);
1543 const T nsum=(-dn1-dn1*dn2-dn1*dn3
1544 +dn2*dn3-dn2*n10-dn3*n10
1545 -dn1*n20+dn3*n20-dn1*n30
1548 S[i]+=0.5*dkl*phi*nsum;
1551 t[i]+=0.5*dkl*phi*(n20+n30+1);
1552 gam2[i]+=0.5*dkl*phi*nsum;
1602 const int klen=
_kspace.getlength();
1603 for(
int i=0;i<Rows;i++)
1605 S[i]*=(preFac*w[i]*hbar);
1608 const T n10=1./(exp(hbar*w[i]/kb/300.)-1);
1609 gam[i]=n10*(n10+1)/preFac/(gam1[i]+gam2[i]);
1622 for(
int k=0;k<klen;k++)
1627 for(
int m=0;m<modenum;m++)
1630 const T tau=mode.
gettau();
1632 const T gamRatio=tau/gam[cnt];
1633 if(gamRatio>maxRatio)
1638 if(gamRatio<minRatio)
1643 defect+=(S[cnt]/maxS)*(dk3/DK3);
1656 for(
int k=0;k<klen;k++)
1661 for(
int m=0;m<modenum;m++)
1664 const T ez=mode.
calce0(Tl);
1671 defect=defect*maxS*DK3;
1677 for(
int k=0;k<klen;k++)
1682 for(
int m=0;m<modenum;m++)
1687 defect+=(S[cnt]/maxS)*(dk3/DK3);
1694 for(
int i=0;i<Rows;i++)
1700 for(
int k=0;k<klen;k++)
1705 for(
int m=0;m<modenum;m++)
1713 cout<<
"New Temp: "<<temp<<endl;
1733 const int Rows(
_kspace.gettotmodes());
1737 for(
int i=0;i<Rows;i++)
1739 for(
int pos=t1p2row[i];pos<t1p2row[i+1];pos++)
1741 const int j2=t1p2col[pos];
1751 for(
int pos2=t1p2row[j2];pos2<t1p2row[j2+1];pos2++)
1753 const int jj2=t1p2col[pos2];
1773 for(
int i=0;i<Dups.getLength();i++)
1782 cout<<
"Duplicated -- "<<duplicated<<endl;
1783 cout<<
"Removed -- "<<removed<<endl;
1790 const int Rows=
_kspace.gettotmodes();
1803 const T hbarJoule=1.054571726e-34;
1804 const T hbar=6.582119e-16;
1805 const T Acell=5.378395621705545e-20;
1806 const T kb=8.617343e-5;
1826 for(
int i=0;i<Rows;i++)
1827 n0[i]=1./(exp(hbar*w[i]/kb/Tl)-1);
1833 for(
int i=0;i<Rows;i++)
1835 const int k1=floor(i/6);
1837 for(
int pos=t1p2row[i];pos<t1p2row[i+1];pos++)
1839 const int j2=t1p2col[pos];
1840 const int k2=floor(j2/6);
1842 const int j3=t1p3col[pos];
1843 const int k3=floor(j3/6);
1845 const T dkl=t1dkl[pos];
1846 const T phi=t1phi[pos];
1848 Gam[i]+=n0[i]*n0[j2]*(n0[j3]+1)*dkl*phi;
1857 for(
int i=0;i<Rows;i++)
1859 const int k1=floor(i/6);
1861 for(
int pos=t2p2row[i];pos<t2p2row[i+1];pos++)
1863 const int j2=t2p2col[pos];
1864 const int k2=floor(j2/6);
1866 const int j3=t2p3col[pos];
1867 const int k3=floor(j3/6);
1869 const T dkl=t2dkl[pos];
1870 const T phi=t2phi[pos];
1872 Gam[i]+=0.5*n0[i]*(n0[j2]+1)*(n0[j3]+1)*phi*dkl;
1878 for(
int i=0;i<Rows;i++)
1883 for(
int i=0;i<Rows;i++)
1885 Psi0[i]=hbarJoule*w[i]*n0[i]*(n0[i]+1)/Gam[i]/Tl*v[i];
1886 Psi[i]=hbarJoule*w[i]*n0[i]*(n0[i]+1)/Gam[i]/Tl*v[i];
1889 Psi0[i]=hbarJoule*w[i]*n0[i]*(n0[i]+1)/Gam[i]/Tl*v[i]*1.1;
1890 Psi[i]=hbarJoule*w[i]*n0[i]*(n0[i]+1)/Gam[i]/Tl*v[i]*1.1;
1897 for(
int its=0;its<totIts;its++)
1900 for(
int i=0;i<Rows;i++)
1902 const int k1=floor(i/6);
1904 for(
int pos=t1p2row[i];pos<t1p2row[i+1];pos++)
1906 const int j2=t1p2col[pos];
1907 const int k2=floor(j2/6);
1909 const int j3=t1p3col[pos];
1910 const int k3=floor(j3/6);
1912 const T dkl=t1dkl[pos];
1913 const T phi=t1phi[pos];
1915 sum[i]+=n0[i]*n0[j2]*(n0[j3]+1)*(Psi[j3]-Psi[j2])*phi*dkl*preFac/Gam[i];
1923 for(
int i=0;i<Rows;i++)
1925 const int k1=floor(i/6);
1927 for(
int pos=t2p2row[i];pos<t2p2row[i+1];pos++)
1929 const int j2=t2p2col[pos];
1930 const int k2=floor(j2/6);
1932 const int j3=t2p3col[pos];
1933 const int k3=floor(j3/6);
1935 const T dkl=t2dkl[pos];
1936 const T phi=t2phi[pos];
1938 sum[i]+=0.5*n0[i]*(n0[j2]+1)*(n0[j3]+1)*(Psi[j3]+Psi[j2])*phi*dkl*preFac/Gam[i];
1941 Psi[i]=sum[i]+Psi0[i];
1954 const int Rows=
_kspace.gettotmodes();
1969 const T hbarJoule=1.054571726e-34;
1971 const T Acell=5.378395621705545e-20;
1973 const T kbJoule=1.3806488e-23;
2004 cout<<
"Temperature: "<<Tl<<endl;
2006 for(
int i=0;i<Rows;i++)
2012 for(
int pos=t1p2row[i];pos<t1p2row[i+1];pos++)
2014 const int j2=t1p2col[pos];
2017 const int j3=t1p3col[pos];
2020 const T dkl=t1dkl[pos];
2021 const T phi=t1phi[pos];
2023 Q[i]+=n0[i]*n0[j2]*(n0[j3]+1)*dkl*phi;
2027 for(
int pos=t2p2row[i];pos<t2p2row[i+1];pos++)
2029 const int j2=t2p2col[pos];
2032 const int j3=t2p3col[pos];
2035 const T dkl=t2dkl[pos];
2036 const T phi=t2phi[pos];
2038 Q[i]+=0.5*n0[i]*(n0[j2]+1)*(n0[j3]+1)*phi*dkl;
2044 for(
int i=0;i<Rows;i++)
2050 for(
int i=0;i<Rows;i++)
2053 P0[i]=C[i]/Q[i]*kbJoule*Tl;
2062 for(
int its=0;its<totIts;its++)
2065 for(
int i=0;i<Rows;i++)
2068 for(
int pos=t1p2row[i];pos<t1p2row[i+1];pos++)
2070 const int j2=t1p2col[pos];
2071 const int j3=t1p3col[pos];
2072 const T dkl=t1dkl[pos];
2073 const T phi=t1phi[pos];
2076 sum+=n0[i]*n0[j2]*(n0[j3]+1)*(P[j3]-P[j2])*phi*dkl*preFac/Q[i];
2079 for(
int pos=t2p2row[i];pos<t2p2row[i+1];pos++)
2081 const int j2=t2p2col[pos];
2082 const int j3=t2p3col[pos];
2083 const T dkl=t2dkl[pos];
2084 const T phi=t2phi[pos];
2087 sum+=0.5*n0[i]*(n0[j2]+1)*(n0[j3]+1)*(P[j3]+P[j2])*phi*dkl*preFac/Q[i];
2091 P[i]=0.75*P[i]+0.25*(sum+P0[i]);
2097 for(
int i=0;i<Rows;i++)
2099 T factor(1+P[i]*(1+n0[i])/kbJoule/Tl);
2101 if(factor>maxChange)
2103 if(factor<minChange)
2107 cout<<
"Max Change: "<<maxChange<<
" Min Change: "<<minChange<<endl;
2113 for(
int i=0;i<Rows;i++)
2115 T factor(1+P[i]*(1+n0[i])/kbJoule/Tl);
2118 newE[i]=n0[i]*(rel*(factor-1)+1);
2120 if(factor>maxChange)
2122 if(factor<minChange)
2126 cout<<
"Max Change: "<<maxChange<<
" Min Change: "<<minChange<<endl;
KSConnectivity< T > _type1Collisions
ScatteringKernel(Kspace< T > &kspace)
Tmode & getmode(int n) const
ArrayBase * IterateToEquilibrium(const T Tl, const int totIts, const T tStep)
KSConnectivity< T > Tksconn
void ReadType2(const string &NamePhonon2, const string &NamePhonon3, const T tol)
void updateSource2(const int c, TArray &S, TArray &dS)
KSConnectivity< T > _type2Collisions
Tangent fabs(const Tangent &a)
void ReadType1(const string &NamePhonon2, const string &NamePhonon3, const T tol)
void getTypeIIsource(const int c, TArray &S, TArray &dS, const bool correct)
void correctDetailedBalance()
ArrayBase * calculatePsi(const int totIts)
Array< VectorT3 > VectorT3Array
void updateSourceTermTest(const T Tl)
void updateSource(const int c, TArray &S)
void getTypeIsource(const int c, TArray &S, TArray &dS, const bool correct)
void updateSourceTerm(const TArray &e, const TArray &w, TArray &S)
void scatterPhonons(const int c, const int totIts, TArray &C, TArray &B, const TArray &V, TArray &newE, const T cv)