00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 void ensemble_montecarlo(void)
00030 {
00031 long int n=1;
00032 int i,ni,j;
00033 double tdt,ti,tau;
00034
00035 tdt=TEMPO+DT;
00036
00037 do{
00038 IV=(int)(P[n][0]);
00039 KX=P[n][1];
00040 KY=P[n][2];
00041 KZ=P[n][3];
00042 TS=P[n][4];
00043 L[0]=P[n][5];
00044 L[1]=P[n][6];
00045 L[2]=P[n][7];
00046 L[3]=P[n][8];
00047
00048 EL=(int)(P[n][9]);
00049
00050 ti=TEMPO;
00051
00052 while(TS<=tdt){
00053 tau=TS-ti;
00054
00055 drift(tau);
00056
00057 scat(i_dom[EL]);
00058 ti=TS;
00059 TS=ti-log(rnd())/GM[i_dom[EL]];
00060 }
00061 tau=tdt-ti;
00062 drift(tau);
00063
00064
00065 if(IV!=9){
00066 P[n][0]=IV;
00067 P[n][1]=KX;
00068 P[n][2]=KY;
00069 P[n][3]=KZ;
00070 P[n][4]=TS;
00071 P[n][5]=L[0];
00072 P[n][6]=L[1];
00073 P[n][7]=L[2];
00074 P[n][8]=L[3];
00075 P[n][9]=EL;
00076 n++;
00077 }
00078
00079 if(IV==9){
00080 for(i=1;i<=9;i++) P[n][i]=P[INUM][i];
00081 INUM--;
00082 }
00083
00084 }while(n<INUM);
00085
00086
00087 for(i=0;i<Ne;i++) NOELEC[i]=0.;
00088 for(n=1;n<=INUM;n++){
00089 int el;
00090 el=(int)(P[n][9]);
00091 if(i_dom[el]==SIO2) NOELEC[el]=0;
00092 if(i_dom[el]!=SIO2) NOELEC[el]++;
00093 }
00094
00095
00096
00097
00098
00099
00100 for(i=0;i<Ne;i++){
00101 int np;
00102 if((i_front[noeud_geo[0][i]-1]==OHMIC
00103 && i_front[noeud_geo[1][i]-1]==OHMIC
00104 && i_front[noeud_geo[2][i]-1]==OHMIC) ||
00105 (i_front[noeud_geo[0][i]-1]==OHMIC
00106 && i_front[noeud_geo[2][i]-1]==OHMIC
00107 && i_front[noeud_geo[3][i]-1]==OHMIC) ||
00108 (i_front[noeud_geo[0][i]-1]==OHMIC
00109 && i_front[noeud_geo[1][i]-1]==OHMIC
00110 && i_front[noeud_geo[3][i]-1]==OHMIC) ||
00111 (i_front[noeud_geo[1][i]-1]==OHMIC
00112 && i_front[noeud_geo[2][i]-1]==OHMIC
00113 && i_front[noeud_geo[3][i]-1]==OHMIC)){
00114
00115
00116 np=(int)(ND[i]*VOLUME[i]/EPP[i]+0.5);
00117 if(ND[i]==0.) np=0;
00118
00119
00120 ni=np-NOELEC[i];
00121
00122
00123 if(ni>0){
00124 n=0;
00125 for(j=1;j<=ni;j++){
00126
00127
00128 if(i_dom[i]!=SIO2){
00129 n++;
00130 creation(i,TEMPO);
00131 P[INUM+n][0]=IV;
00132 P[INUM+n][1]=KX;
00133 P[INUM+n][2]=KY;
00134 P[INUM+n][3]=KZ;
00135 P[INUM+n][4]=TS;
00136 P[INUM+n][5]=L[0];
00137 P[INUM+n][6]=L[1];
00138 P[INUM+n][7]=L[2];
00139 P[INUM+n][8]=L[3];
00140 P[INUM+n][9]=i;
00141 }
00142 }
00143 INUM += n;
00144 }
00145 }
00146 }
00147
00148 printf("Actual number of electron super-particles = %d\n",INUM);
00149 if(INUM>NPMAX){
00150 printf("ensemble_montecarlo : too big actual number of particles\n");
00151 exit(EXIT_FAILURE);
00152 }
00153 }