Main Page | Directories | File List | File Members

aeneas.c

Go to the documentation of this file.
00001 /*
00002    This file belongs to Aeneas. Aeneas is a GNU package released under GPL 3.
00003    This code is a simulator for Submicron 3D Semiconductor Devices. 
00004    It implements the Monte Carlo transport in 3D tetrahedra meshes
00005    for the simulation of the semiclassical Boltzmann equation for both electrons.
00006    It also includes all the relevant quantum effects for nanodevices.
00007 
00008    Copyright (C) 2007 Jean Michel Sellier <sellier@dmi.unict.it>
00009                                           <aeneas@southnovel.eu>
00010  
00011    This program is free software; you can redistribute it and/or modify
00012    it under the terms of the GNU General Public License as published by
00013    the Free Software Foundation; either version 3, or (at your option)
00014    any later version.
00015 
00016    This program is distributed in the hope that it will be useful,
00017    but WITHOUT ANY WARRANTY; without even the implied warranty of
00018    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019    GNU General Public License for more details.
00020 
00021    You should have received a copy of the GNU General Public License
00022    along with this program. If not, see <http://www.gnu.org/licenses/>.
00023 */
00024 
00025 /*
00026  ************************************************************************
00027 
00028   Program Name              : Aeneas (GNU package)
00029   Version                   : 1.1
00030   File Name                 : aeneas.c
00031   Programmer                : Jean Michel Sellier
00032   Copyright                 : 2007, Jean Michel Sellier
00033   Input File                : specified by the user
00034   Output file               : various mesh, BB, vtk, 3D output files
00035   Created on                : 06 june 2007 Siracusa, Jean Michel Sellier
00036   Last modified on          : 16 september 2007 Siracusa, Jean Michel Sellier
00037   Description               : Monte Carlo simulation of the Wigner equation
00038                               on a 3D unstructured mesh.
00039   Dependencies              : None
00040 
00041   Comments                  : WARNING!!! The input mesh file is described in micron!!!
00042 
00043   Important bibliography    : Elements finis: theorie, applications, mise en oeuvre ,
00044                               Alexandre Ern, Jean-Luc Guermond, SMAI, Springer (french book).
00045 
00046                               Numerical Simulation of Submicron Semiconductor Devices,
00047                               Kazutaka Tomizawa, Artech House (english book).
00048   ************************************************************************
00049 */
00050 
00051 #include<getopt.h>
00052 #include<stdio.h>
00053 #include<math.h>
00054 #include<stdlib.h>
00055 #include<memory.h>
00056 #include<string.h>
00057 #include<time.h>
00058 //#include<gl/gl.h>
00059 //#include<gl/glu.h>
00060 //#include<gl/glut.h>
00061 
00062 
00063 // the following will be changed once the dynamic allocation will be implemented
00064 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
00065 #define MAXNUMELEMENTS 100000  // maximum number of elements per mesh
00066 #define MAXNUMNODES 10000 // maximum number of nodes per mesh
00067 #define NPMAX 5000000        // maximum number of particles
00068 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
00069 
00070 // read and write
00071 #define READ  0
00072 #define WRITE 1
00073 
00074 // yes and no
00075 #define NO  0
00076 #define YES 1
00077 
00078 // definition of various output format flags
00079 #define POINT3D 0
00080 #define VTK     1
00081 #define MESH    2
00082 #define ALL     100
00083 
00084 // definition of the material reference table
00085 #define NOAMTIA 13   // Number Of All Material Taken Into Account (excluding SiO2)
00086 // ********************
00087 #define SIO2 -1      // reference number to Silicon Oxide
00088 #define SILICON 0    // reference number to Silicon
00089 #define GAAS 1       // reference number to GaAs
00090 #define GERMANIUM 2  // reference number to Germanium
00091 #define INSB 3       // reference number to InSb
00092 #define ALSB 4       // reference number to AlSb
00093 #define ALXINXSB 5   // reference number to Al_x In_x Sb
00094 #define ALXIN1XSB 6  // reference number to Al_x In_(1-x) Sb
00095 #define ALAS 7       // reference number to AlAs
00096 #define ALP 8        // reference number to AlP
00097 #define GAP 9        // reference number to GaP
00098 #define GASB 10      // reference number to GaSb
00099 #define INAS 11      // reference number to InAs
00100 #define INP 12       // reference number to InP
00101 // ********************
00102 
00103 // definition of the various possible contacts
00104 #define NOCONTACT -1
00105 #define INSULATOR 0
00106 #define OHMIC     1
00107 #define SCHOTTKY  2
00108 #define CONTACT   3  // applied voltage -- with no carrier reservoir 
00109                      // and no carrier can go outside this contact
00110 
00111 // maximum number of steps in the discretised energy
00112 #define DIME 2003
00113 
00114 // Definition of all the physical constants
00115 // The system used is the following :
00116 //   [L] = Angstrom
00117 //   [M] = 1.e-31 Kg
00118 //   [T] = picosecond
00119 //   [C] = 1.e-19 Coulomb
00120 
00121 double EPSR[NOAMTIA+1];
00122 double EPF[NOAMTIA+1];
00123 double alphaK[NOAMTIA+1][4];
00124 double EMIN[NOAMTIA+1][4];
00125 double HWO[NOAMTIA+1][6];
00126 double DTK[NOAMTIA+1][6];
00127 double ZF[NOAMTIA+1][6];
00128 double RHO[NOAMTIA+1];
00129 double DA[NOAMTIA+1];
00130 double UL[NOAMTIA+1];
00131 double EG[NOAMTIA+1];
00132 double PII[NOAMTIA+1];
00133 double ETH[NOAMTIA+1];
00134 
00135 // permittivity of vacuum [C]*V^-1*Angstrom^-1 (this definition is used
00136 // only in the assemble_matrix_A routine)
00137 const double epslon0=8.854187817e-3;
00138 // Relative Permittivity of Silicon Oxide (SiO2)
00139 const double EPSR_SiO2=3.9;
00140 
00141 double VIC[MAXNUMNODES+1]; // Volt on the I-th vertex (Contact)
00142 
00143 const double thresh=1.e-16; // threshold value for linear sparse solver 
00144 
00145 const double EPS=1.e-16;
00146 
00147 const double TINY=1.e-16;
00148 
00149 // \hat{\psi}_n(\hat{\xi}_l) see pag.322 of the french book
00150 double base_geo[4][4]; // i=1..ng, j=1..lg
00151 
00152 // \hat{\theta}_n(\hat{\xi}_l) see pag.322 of the french book
00153 double base_ref[4][4]; // i=1..nf, j=1..lg
00154 
00155 // \frac{\partial \hat{\psi}_n}{\partial \hat{x}_k}(\hat{\xi}_l) see pag.323 of the french book
00156 double d_base_geo[3][4]; // k=1..dim, i=1..ng
00157 
00158 // \frac{\partial \hat{\theta}_n}{\partial \hat{x}_k}(\hat{\xi}_l) see pag.323 of the french book
00159 double d_base_ref[3][4]; // k=1..dim, i=1..nf
00160 
00161 // The following declarations are related to the mesh
00162 // *****
00163 int Ng; // Number of vertices
00164 int Ne; // Number of elements
00165 int ng = 4; // Number of vertices per element
00166 int nf = 4; // Number of degree of freedom
00167 int dim = 3; // dimension of the space
00168 int i_front[MAXNUMNODES+1];
00169 int i_dom[MAXNUMELEMENTS+1];
00170 int noeud_geo[4][MAXNUMELEMENTS+1]; // i=1..ng
00171 double coord[3][MAXNUMNODES+1]; // i=1..dim
00172 // *****
00173 
00174 // Global Gaussian quadrature weights
00175 double poids_K[4][MAXNUMELEMENTS+1]; // i=1..lg, j=1..Ne
00176 
00177 // elements of the inverse jacobian for the various transformations
00178 double inv_jac_K[3][3][MAXNUMELEMENTS+1]; // i=1..dim, j=1..dim, k=1..Ne
00179 
00180 // derivee d'une fonction de forme globale
00181 double d_base_K[3][4][MAXNUMELEMENTS+1]; // i=1..dim, j=1..nf, m=1..Ne
00182 
00183 // neighbourhood table
00184 int vois[4][MAXNUMELEMENTS+1];
00185 
00186 // the right hand side vector for the 3D Poisson equation
00187 double b[MAXNUMNODES+1];
00188 
00189 // the electrostatic potential calculated by Poisson 3D
00190 double V[MAXNUMNODES+1];
00191 double Vi[MAXNUMNODES+1]; // initial applied potential
00192 
00193 // the electric field components
00194 double Ex[MAXNUMNODES+1];
00195 double Ey[MAXNUMNODES+1];
00196 double Ez[MAXNUMNODES+1];
00197 
00198 // for the linear solver part...
00199 int ija[100*MAXNUMELEMENTS+1];
00200 double sa[100*MAXNUMELEMENTS+1];
00201 
00202 // Gauss coordinates and weights
00203 // Gauss integration with power p=4 in the polynomial in xi[0], xi[1], xi[2].
00204 int lg = 4; // number of points for the standard Gauss integration (formule de quadrature a' lg points)
00205 double xi[3][4]; // i=1..dim, j=1..lg
00206 double omega[4]; // i=1..lg
00207 
00208 // some variables for the linear biconjugate gradient method
00209 int itol;
00210 int itmax;
00211 int Quantum_Flag;
00212 double tol;
00213 
00214 double p[MAXNUMNODES+2];
00215 double pp[MAXNUMNODES+2];
00216 double r[MAXNUMNODES+2];
00217 double rr[MAXNUMNODES+2];
00218 double z[MAXNUMNODES+2];
00219 double zz[MAXNUMNODES+2];
00220 
00221 // time structures
00222 time_t binarytime;
00223 struct tm *nowtm;
00224 
00225 time_t fbinarytime;
00226 struct tm *fnowtm;
00227 
00228 // MC variables
00229 int EL;
00230 int number_of_steps, it;
00231 int NOVALLEY[NOAMTIA+1]; // see montecarlo_setup.h for more informations
00232 int ISEED, NP1, INUM, IV;
00233 int NOELEC[MAXNUMELEMENTS+1];
00234 int MEAN;
00235 //double **resr;
00236 double  *da;  // k = 1./epsr*eps0
00237 double *NA;
00238 double *ND, DT, TS, *NE;
00239 double KX, KY, KZ, TF;
00240 double DDMAX, *EPP, L[4];
00241 double P[NPMAX+1][10];
00242 double BKTQ, QH, TL, CIMP, QD2;
00243 double MSTAR[NOAMTIA+1][6];
00244 double *VOLUME, TEMPO;
00245 double SWK[NOAMTIA+1][3][15][DIME+1];
00246 double AF[NOAMTIA+1][3],EC[NOAMTIA+1][3];
00247 double HM[NOAMTIA+1][3],GM[NOAMTIA+1];
00248 double SMH[NOAMTIA+1][3],HHM[NOAMTIA+1][3];
00249 
00250 double *XVEL; // X-component of Velocity of ELectrons
00251 double *YVEL; // Y-component of Velocity of ELectrons
00252 double *ZVEL; // Z-component of Velocity of ELectrons
00253 double *ENEL; // ENergy of ELectrons
00254 
00255 int err;
00256 int every_num_steps;
00257 int NHTFLAG;
00258 int POISSONUPDATEFLAG;
00259 int SAVEPARTICLESFLAG;
00260 int SAVEPARTICLESFORMAT;
00261 int SAVEFIELDSFLAG;
00262 int SAVEFIELDSFORMAT;
00263 
00264 int NPMAX0;
00265 int WINX,WINY;
00266 double up,down;
00267 
00268 // Impact Ionization flag
00269 int IIFLAG;
00270 
00271 char MESHNAME[256];
00272 double XVAL[NOAMTIA+1];
00273 
00274 //int RELATIVEDISTANCESFLAG;
00275 
00276 // All files here...
00277 FILE *fp;
00278 
00279 struct option longopts[] =
00280 {
00281   { "version", no_argument, NULL, 'v' },
00282   { "help", no_argument, NULL, 'h' }
00283 };
00284 
00285 // All strings here...
00286 static char *progname;
00287 
00288 //int the_main_single_step(void);
00289 #include "headers/included_files.h"
00290 
00291 // ********************************************************************
00292 //                         M    A    I    N
00293 // ********************************************************************
00294 
00295 int main(int argc, char *argv[])
00296 {
00297  int index;
00298  int optc;
00299  int h = 0, v = 0, lose = 0, z = 0;
00300 
00301   progname = argv[0];
00302 
00303   while ((optc = getopt_long (argc, argv, "hv", longopts, (int *) 0))
00304          != EOF)
00305     switch (optc)
00306       {
00307       case 'v':
00308         v = 1;
00309         break;
00310       case 'h':
00311         h = 1;
00312         break;
00313       default:
00314         lose = 1;
00315         break;
00316       }
00317   
00318   if (optind == argc - 1)
00319     z = 1;
00320   else if (lose || optind < argc)
00321     {
00322       /* Print error message and exit.  */
00323       if (optind < argc)
00324         printf("Too many arguments\n");
00325         printf("Try `%s --help' for more information.\n",progname);
00326       exit(1);
00327     }
00328 
00329   /* `help' should come first.  If `help' is requested, ignore the other
00330      options. */
00331   if (h)
00332     {
00333       /* Print help info and exit.  */
00334       /* TRANSLATORS: --help output 1
00335          no-wrap */
00336       printf("\
00337 Aeneas, the GNU 3D simulator for III-V semiconductor devices.\n");
00338       printf ("\n");
00339       /* TRANSLATORS: --help output 2
00340          no-wrap */
00341       printf ("\
00342 Usage: %s [OPTION] file...\n",progname);
00343 
00344       printf ("\n");
00345       /* TRANSLATORS: --help output 3 : options 1/2
00346          no-wrap */
00347       printf("\
00348   -h, --help          display this help and exit\n\
00349   -v, --version       display version information and exit\n");
00350 
00351       printf ("\n");
00352       /* TRANSLATORS: --help output 5 (end)
00353          TRANSLATORS, please don't forget to add the contact address for
00354          your translation!
00355          no-wrap */
00356       printf ("\
00357 Report bugs to sellier@dmi.unict.it or aeneas@southnovel.eu\n");
00358 
00359       exit (0);
00360     }
00361 
00362   if (v)
00363     {
00364       /* Print version number.  */
00365       printf("aeneas - GNU aeneas 1.1\n");
00366       /* xgettext: no-wrap */
00367       printf("\n");
00368       printf("\
00369 Copyright (C) %s Sellier Jean Michel.\n\
00370 There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n\
00371 PARTICULAR PURPOSE.\n\
00372 You may redistribute copies of GNU %s under the terms\n\
00373 of the GNU General Public License.\n\
00374 For more information about these matters, see the file named COPYING.\n",
00375               "2007","Aeneas");
00376       exit (0);
00377     }
00378   else if (z){
00379 // In case of filename specified
00380 // =============================
00381      fp=fopen(argv[1],"r"); // here we open th input file...
00382 // File Control, just in case the file does not exist...
00383      if(fp==NULL){
00384       printf("%s: fatal error in opening the input file %s\n",
00385              progname,argv[1]);
00386       exit(EXIT_FAILURE);
00387      }
00388 
00389 // =========================
00390 
00391 // creation of the output directories
00392   printf("\ntrying to create the output directories.\n");
00393   err = system("mkdir e_density");
00394   err = system("mkdir e_density/BB_mesh_format");
00395   err = system("mkdir e_density/VTK_format");
00396   err = system("mkdir e_velocity");
00397   err = system("mkdir e_velocity/xvel_BB_mesh_format");
00398   err = system("mkdir e_velocity/yvel_BB_mesh_format");
00399   err = system("mkdir e_velocity/zvel_BB_mesh_format");
00400   err = system("mkdir e_velocity/VTK_format");
00401   err = system("mkdir e_energy");
00402   err = system("mkdir e_energy/BB_mesh_format");
00403   err = system("mkdir e_energy/VTK_format");
00404   err = system("mkdir E");
00405   err = system("mkdir E/Ex_BB_mesh_format");
00406   err = system("mkdir E/Ey_BB_mesh_format");
00407   err = system("mkdir E/Ez_BB_mesh_format");
00408   err = system("mkdir E/VTK_format");
00409   err = system("mkdir e_current");
00410   err = system("mkdir e_current/e_current_x_BB_mesh_format");
00411   err = system("mkdir e_current/e_current_y_BB_mesh_format");
00412   err = system("mkdir e_current/e_current_z_BB_mesh_format");
00413   err = system("mkdir e_current/VTK_format");
00414   err = system("mkdir potential");
00415   err = system("mkdir potential/BB_mesh_format");
00416   err = system("mkdir potential/VTK_format");
00417   err = system("mkdir particles");
00418   err = system("mkdir particles/position_mesh_format");
00419   err = system("mkdir particles/position_Point3D_format");
00420   err = system("mkdir particles/energy_Point3D_format");
00421   err = system("mkdir particles/potential_Point3D_format");
00422 
00423 // Printing of the initial runtime
00424 // ===============================
00425   binarytime=time(NULL);
00426   nowtm=localtime(&binarytime);
00427   printf("\n\nSimulation started : %s\n",asctime(nowtm));
00428 
00429 
00430 //  initial value for random number generator
00431   ISEED = 38467.;
00432 
00433 // Open the input file and check if it exists
00434 // If the input file does not exist then the code stops.
00435 //  printf("\n\nLoading the input mesh file...\n");
00436 //  if(1) load_mesh(); // this row has to be putted before everything calculation!!!
00437 //  if(0) load_mshV1(); // this subroutine is recommended only for GMSH experts
00438 // warning : the user has to be very experienced in GMSH
00439 
00440 // ***************************
00441 // HERE WE READ THE INPUT FILE
00442 // ***************************
00443   read_input_file();
00444 
00445 // closure of the user specified input file
00446   fclose(fp);
00447 
00448 // If no error has occured then print a nice message :)
00449   printf("Mesh input file correctly processed...\n\n");
00450 
00451 // ==============================
00452 // ==============================
00453 // ========================
00454 // Material constants here!
00455 // ========================
00456 // Silicon electrons in the X-valley
00457 // Germanium electrons in the X-valley
00458 // All the other semiconductor compounds have electrons in the Gamma- and L-valley
00459 // definition of the number of valley for every material
00460  NOVALLEY[SILICON]=1;
00461  NOVALLEY[GAAS]=2;
00462  NOVALLEY[GERMANIUM]=1;
00463  NOVALLEY[INSB]=2;
00464  NOVALLEY[ALSB]=2;
00465  NOVALLEY[ALAS]=2;
00466  NOVALLEY[ALP]=2;
00467  NOVALLEY[GAP]=2;
00468  NOVALLEY[GASB]=2;
00469  NOVALLEY[INAS]=2;
00470  NOVALLEY[INP]=2;
00471  NOVALLEY[ALXINXSB]=2;
00472  NOVALLEY[ALXIN1XSB]=2;
00473 // Relative dielectric constant for Silicon
00474  EPSR[SILICON]=11.7;
00475 // Relative dielectric constant for Germanium
00476  EPSR[GERMANIUM]=16.2;
00477 // Relative dielectric constant for InSb
00478  EPSR[INSB]=17.65;
00479 // Relative dieletric constant for GaAs
00480  EPSR[GAAS]=12.90;
00481 // Relative dieletric constant for AlSb
00482  EPSR[ALSB]=12.04;
00483 // Relative dieletric constant for AlAs
00484  EPSR[ALAS]=10.06;
00485 // Relative dieletric constant for AlP
00486  EPSR[ALP]=9.80;
00487 // Relative dieletric constant for GaP
00488  EPSR[GAP]=11.10;
00489 // Relative dieletric constant for GaSb
00490  EPSR[GASB]=15.69;
00491 // Relative dieletric constant for InAs
00492  EPSR[INAS]=15.15;
00493 // Relative dieletric constant for InP
00494  EPSR[INP]=12.61;
00495 // Relative dieletric constant for Al_x In_x Sb
00496  EPSR[ALXINXSB]=XVAL[ALXINXSB]*EPSR[ALSB]+XVAL[ALXINXSB]*EPSR[INSB];
00497 // Relative dieletric constant for Al_x In_(1-x) Sb
00498  EPSR[ALXIN1XSB]=XVAL[ALXIN1XSB]*EPSR[ALSB]+(1.-XVAL[ALXIN1XSB])*EPSR[INSB];
00499 // InSb high frequency dieletric constant
00500  EPF[INSB]=15.68;
00501 // GaAs high frequency dieletric constant
00502  EPF[GAAS]=10.92;
00503 // AlSb high frequency dieletric constant
00504  EPF[ALSB]=9.88;
00505 // AlAs high frequency dieletric constant
00506  EPF[ALAS]=8.16;
00507 // AlP high frequency dieletric constant
00508  EPF[ALP]=7.54;
00509 // GaP high frequency dieletric constant
00510  EPF[GAP]=9.08;
00511 // GaSb high frequency dieletric constant
00512  EPF[GASB]=14.44;
00513 // InAs high frequency dieletric constant
00514  EPF[INAS]=12.75;
00515 // InP high frequency dieletric constant
00516  EPF[INP]=9.61;
00517 // Al_x In_x Sb high frequency dieletric constant
00518  EPF[ALXINXSB]=XVAL[ALXINXSB]*(EPF[ALSB]+EPF[INSB]);
00519 // Al_x In_(1-x) Sb high frequency dieletric constant
00520  EPF[ALXIN1XSB]=XVAL[ALXIN1XSB]*EPF[ALSB]+(1.-XVAL[ALXIN1XSB])*EPF[INSB];
00521  for(index=0;index<NOAMTIA;index++){
00522    int i;
00523    for(i=0;i<6;i++){
00524      HWO[index][i]=0.;
00525      DTK[index][i]=0.;
00526      ZF[index][i]=0.;
00527    }
00528  }
00529 // Silicon optical phonon scattering energy (eV)
00530  HWO[SILICON][0]=0.0120;
00531  HWO[SILICON][1]=0.0185;
00532  HWO[SILICON][2]=0.0190;
00533  HWO[SILICON][3]=0.0474;
00534  HWO[SILICON][4]=0.0612;
00535  HWO[SILICON][5]=0.0590;
00536 // Germanium optical phonon scattering energy (eV)
00537  HWO[GERMANIUM][0]=0.09;
00538 // InSb optical phonon scattering energy (eV)
00539  HWO[INSB][0]=0.0282;
00540 // GaAs optical phonon scattering energy (eV)
00541  HWO[GAAS][0]=0.03536;
00542 // AlSb optical phonon scattering energy (eV)
00543  HWO[ALSB][0]=0.0360;
00544 // AlAs optical phonon scattering energy (eV)
00545  HWO[ALAS][0]=0.05009;
00546 // AlP optical phonon scattering energy (eV)
00547  HWO[ALP][0]=0.06212;
00548 // GaP optical phonon scattering energy (eV)
00549  HWO[GAP][0]=0.04523;
00550 // GaSb optical phonon scattering energy (eV)
00551  HWO[GASB][0]=0.02529;
00552 // InAs optical phonon scattering energy (eV)
00553  HWO[INAS][0]=0.03008;
00554 // InP optical phonon scattering energy (eV)
00555  HWO[INP][0]=0.04240;
00556 // Al_x In_x Sb optical phonon scattering energy (eV)
00557  HWO[ALXINXSB][0]=XVAL[ALXINXSB]*(HWO[ALSB][0]+HWO[INSB][0]);
00558 // Al_x In_(1-x) Sb optical phonon scattering energy (eV)
00559  HWO[ALXIN1XSB][0]=XVAL[ALXIN1XSB]*HWO[ALSB][0]+(1.-XVAL[ALXIN1XSB])*HWO[INSB][0];
00560 // Silicon optical coupling constants (eV/m)
00561  DTK[SILICON][0]=0.05e11;
00562  DTK[SILICON][1]=0.08e11;
00563  DTK[SILICON][2]=0.03e11;
00564  DTK[SILICON][3]=0.20e11;
00565  DTK[SILICON][4]=1.14e11;
00566  DTK[SILICON][5]=0.20e11;
00567 // Germanium optical coupling constants (eV/m)
00568  DTK[GERMANIUM][0]=1.889e11;
00569 // InSb optical coupling constants (eV/m)
00570  DTK[INSB][0]=0.47e11;
00571 // GaAs optical coupling constant (eV/m)
00572  DTK[GAAS][0]=1.11e11;
00573 // AlSb optical coupling constants (eV/m)
00574  DTK[ALSB][0]=0.55e11;
00575 // AlAs optical coupling constants (eV/m)
00576  DTK[ALAS][0]=3.0e11;
00577 // AlP optical coupling constants (eV/m)
00578  DTK[ALP][0]=0.95e11;
00579 // GaP optical coupling constants (eV/m)
00580  DTK[GAP][0]=5.33e11;
00581 // GaSb optical coupling constants (eV/m)
00582  DTK[GASB][0]=0.94e11;
00583 // InAs optical coupling constants (eV/m)
00584  DTK[INAS][0]=3.59e11;
00585 // InP optical coupling constants (eV/m)
00586  DTK[INP][0]=2.46e11;
00587 // Al_x In_x Sb optical coupling constants (eV/m)
00588  DTK[ALXINXSB][0]=XVAL[ALXINXSB]*(DTK[ALSB][0]+DTK[INSB][0]);
00589 // Al_x In_(1-x) Sb optical coupling constants (eV/m)
00590  DTK[ALXIN1XSB][0]=XVAL[ALXIN1XSB]*DTK[ALSB][0]+(1.-XVAL[ALXIN1XSB])*DTK[INSB][0];
00591 // Silicon optical phonon Z-factor
00592  ZF[SILICON][0]=1.;
00593  ZF[SILICON][1]=1.;
00594  ZF[SILICON][2]=4.;
00595  ZF[SILICON][3]=4.;
00596  ZF[SILICON][4]=1.;
00597  ZF[SILICON][5]=4.;
00598 // Germanium optical phonon Z-factor
00599  ZF[GERMANIUM][0]=1.;
00600 // InSb optical phonon Z-factor
00601  ZF[INSB][0]=1.;
00602 // AlSb optical phonon Z-factor
00603  ZF[ALSB][0]=1.;
00604 // optical phonon Z-factor
00605  ZF[ALAS][0]=1.;
00606 // optical phonon Z-factor
00607  ZF[ALP][0]=1.;
00608 // optical phonon Z-factor
00609  ZF[GAP][0]=1.;
00610 // optical phonon Z-factor
00611  ZF[GASB][0]=1.;
00612 // optical phonon Z-factor
00613  ZF[INAS][0]=1.;
00614 // optical phonon Z-factor
00615  ZF[INP][0]=1.;
00616 // Al_x In_x Sb optical phonon Z-factor
00617  ZF[ALXINXSB][0]=XVAL[ALXINXSB]*(ZF[ALSB][0]+ZF[INSB][0]);
00618 // Al_x In_(1-x) Sb optical phonon Z-factor
00619  ZF[ALXIN1XSB][0]=XVAL[ALXIN1XSB]*ZF[ALSB][0]+(1.-XVAL[ALXIN1XSB])*ZF[INSB][0];
00620 // Silicon Crystal Density (Kg/m^3)
00621  RHO[SILICON]=2330.;
00622 // Germanium Crystal Density (Kg/m^3)
00623  RHO[GERMANIUM]=5320.;
00624 // InSb Crystal Density (Kg/m^3)
00625  RHO[INSB]=5790.;
00626 // GaAs Crystal Density (Kg/m^3)
00627  RHO[GAAS]=5360.;
00628 // AlSb Crystal Density (Kg/m^3)
00629  RHO[ALSB]=4288.;
00630 // AlAs Crystal Density (Kg/m^3)
00631  RHO[ALAS]=5650.;
00632 // AlP Crystal Density (Kg/m^3)
00633  RHO[ALP]=7410.;
00634 // GaP Crystal Density (Kg/m^3)
00635  RHO[GAP]=5850.;
00636 // GaSb Crystal Density (Kg/m^3)
00637  RHO[GASB]=3970.;
00638 // InAs Crystal Density (Kg/m^3)
00639  RHO[INAS]=4280.;
00640 // InP Crystal Density (Kg/m^3)
00641  RHO[INP]=5130.;
00642 // Al_x In_x Sb Crystal Density (Kg/m^3)
00643  RHO[ALXINXSB]=XVAL[ALXINXSB]*(RHO[ALSB]+RHO[INSB]); 
00644 // Al_x In_(1-x) Sb Crystal Density (Kg/m^3)
00645  RHO[ALXIN1XSB]=XVAL[ALXIN1XSB]*RHO[ALSB]+(1.-XVAL[ALXIN1XSB])*RHO[INSB];
00646 // Silicon acoustic deformation potential (Joule)
00647  DA[SILICON]=9.*1.60217733e-19;
00648 // Germanium acoustic deformation potential (Joule)
00649  DA[GERMANIUM]=9.*1.60217733e-19;
00650 // InSb acoustic deformation potential (Joule)
00651  DA[INSB]=5.96*1.60217733e-19;
00652 // GaAs acoustic deformation potential (Joule)
00653  DA[GAAS]=7.*1.60217733e-19;
00654 // AlSb acoustic deformation potential (Joule)
00655  DA[ALSB]=4.6*1.60217733e-19;
00656 // acoustic deformation potential (Joule)
00657  DA[ALAS]=9.3*1.60217733e-19;
00658 // acoustic deformation potential (Joule)
00659  DA[ALP]=9.3*1.60217733e-19;
00660 // acoustic deformation potential (Joule)
00661  DA[GAP]=7.4*1.60217733e-19;
00662 // acoustic deformation potential (Joule)
00663  DA[GASB]=9.*1.60217733e-19;
00664 // acoustic deformation potential (Joule)
00665  DA[INAS]=8.2*1.60217733e-19;
00666 // acoustic deformation potential (Joule)
00667  DA[INP]=6.2*1.60217733e-19;
00668 // Al_x In_x Sb acoustic deformation potential (Joule)
00669  DA[ALXINXSB]=XVAL[ALXINXSB]*(DA[ALSB]+DA[INSB]);
00670 // Al_x In_(1-x) Sb acoustic deformation potential (Joule)
00671  DA[ALXIN1XSB]=XVAL[ALXIN1XSB]*DA[ALSB]+(1.-XVAL[ALXIN1XSB])*DA[INSB];
00672 // Silicon longitudinal sound velocity (m/sec)
00673  UL[SILICON]=9040.;
00674 // Germanium longitudinal sound velocity (m/sec)
00675  UL[GERMANIUM]=5400.;
00676 // InSb longitudinal sound velocity (m/sec)
00677  UL[INSB]=4060.;
00678 // GaAs longitudinal sound velocity (m/sec)
00679  UL[GAAS]=5240.;
00680 // AlSb longitudinal sound velocity (m/sec)
00681  UL[ALSB]=4600.;
00682 // longitudinal sound velocity (m/sec)
00683  UL[ALAS]=5650.;
00684 // longitudinal sound velocity (m/sec)
00685  UL[ALP]=7410.;
00686 // longitudinal sound velocity (m/sec)
00687  UL[GAP]=5850.;
00688 // longitudinal sound velocity (m/sec)
00689  UL[GASB]=3970.;
00690 // longitudinal sound velocity (m/sec)
00691  UL[INAS]=4280.;
00692 // longitudinal sound velocity (m/sec)
00693  UL[INP]=5130.;
00694 // Al_x In_x Sb longitudinal sound velocity (m/sec)
00695  UL[ALXINXSB]=XVAL[ALXINXSB]*(UL[ALSB]+UL[INSB]);
00696 // Al_x In_(1-x) Sb longitudinal sound velocity (m/sec)
00697  UL[ALXIN1XSB]=XVAL[ALXIN1XSB]*UL[ALSB]+(1.-XVAL[ALXIN1XSB])*UL[INSB];
00698 // Silicon energy gap
00699  EG[SILICON]=1.21-3.333e-4*TL;
00700  printf("EG[SILICON]      = %g\n",EG[SILICON]);
00701 // Germanium energy gap
00702  EG[GERMANIUM]=0.747-3.587e-4*TL;
00703  printf("EG[GERMANIUM]    = %g\n",EG[GERMANIUM]);
00704 // InSb energy gap
00705  EG[INSB]=0.2446-2.153e-4*TL;//0.174;???
00706  printf("EG[INSB]         = %g\n",EG[INSB]);
00707 // GaAs energy gap
00708  EG[GAAS]=1.54-4.036e-4*TL;//0.32;???
00709  printf("EG[GAAS]         = %g\n",EG[GAAS]);
00710 // AlSb energy gap
00711  EG[ALSB]=1.696-2.20e-4*TL;
00712  printf("EG[ALSB]         = %g\n",EG[ALSB]);
00713 // energy gap
00714  EG[ALAS]=2.314-3.0e-4*TL;
00715 // energy gap
00716  EG[ALP]=2.51-3.333e-4*TL;
00717 // energy gap
00718  EG[GAP]=2.35-2.667e-4*TL;
00719 // energy gap
00720  EG[GASB]=0.81-3.667e-4*TL;
00721 // energy gap
00722  EG[INAS]=0.434-2.601e-4*TL;
00723 // energy gap
00724  EG[INP]=1.445-3.296e-4*TL;
00725 // Al_x In_x Sb energy gap
00726  EG[ALXINXSB]=XVAL[ALXINXSB]*(EG[ALSB]+EG[INSB]);
00727  printf("EG[ALxINxSB]     = %g\n",EG[ALXINXSB]);
00728 // Al_x In_(1-x) Sb energy gap
00729  EG[ALXIN1XSB]=XVAL[ALXIN1XSB]*EG[ALSB]+(1.-XVAL[ALXIN1XSB])*EG[INSB];
00730  printf("EG[ALxIN(1-x)SB] = %g\n",EG[ALXIN1XSB]);
00731  printf("\n");
00732 // Silicon energy minimum
00733  EMIN[SILICON][1]=0.0;
00734 // Germanium energy minimum
00735  EMIN[GERMANIUM][1]=0.173;
00736 // InSb energy minimum of GAMMA-valley
00737  EMIN[INSB][1]=0.0;
00738 // InSb energy minimum 0f L-valley
00739  EMIN[INSB][2]=1.038;
00740 // GaAs energy minimum of GAMMA-valley
00741  EMIN[GAAS][1]=0.0;
00742 // GaAs energy minimum of L-valley (eV)
00743  EMIN[GAAS][2]=0.323;
00744 // AlSb energy minimum of GAMMA-valley
00745  EMIN[ALSB][1]=0.507;
00746 // AlSb energy minimum 0f L-valley
00747  EMIN[ALSB][2]=0.292;
00748 // energy minimum of GAMMA-valley
00749  EMIN[ALAS][1]=0.767;
00750 // energy minimum 0f L-valley
00751  EMIN[ALAS][2]=0.332;
00752 // energy minimum of GAMMA-valley
00753  EMIN[ALP][1]=1.237;
00754 // energy minimum 0f L-valley
00755  EMIN[ALP][2]=0.824;
00756 // energy minimum of GAMMA-valley
00757  EMIN[GAP][1]=0.496;
00758 // energy minimum 0f L-valley
00759  EMIN[GAP][2]=0.415;
00760 // energy minimum of GAMMA-valley
00761  EMIN[GASB][1]=0.0;
00762 // energy minimum 0f L-valley
00763  EMIN[GASB][2]=0.217;
00764 // energy minimum of GAMMA-valley
00765  EMIN[INAS][1]=0.0;
00766 // energy minimum 0f L-valley
00767  EMIN[INAS][2]=1.078;
00768 // energy minimum of GAMMA-valley
00769  EMIN[INP][1]=0.0;
00770 // energy minimum 0f L-valley
00771  EMIN[INP][2]=0.832;
00772 // Al_x In_x Sb energy minimum of GAMMA-valley
00773  EMIN[ALXINXSB][1]=XVAL[ALXINXSB]*(EMIN[ALSB][1]+EMIN[INSB][1]);
00774 // Al_x In_x Sb energy minimum 0f L-valley
00775  EMIN[ALXINXSB][2]=XVAL[ALXINXSB]*(EMIN[ALSB][2]+EMIN[INSB][2]);
00776 // Al_x In_(1-x) Sb energy minimum of GAMMA-valley
00777  EMIN[ALXIN1XSB][1]=XVAL[ALXIN1XSB]*EMIN[ALSB][1]+(1.-XVAL[ALXIN1XSB])*EMIN[INSB][1];
00778 // Al_x In_(1-x) Sb energy minimum 0f L-valley
00779  EMIN[ALXIN1XSB][2]=XVAL[ALXIN1XSB]*EMIN[ALSB][2]+(1.-XVAL[ALXIN1XSB])*EMIN[INSB][2];
00780 // Definition of effective mass for all materials in all valleys
00781  MSTAR[SILICON][1]=0.32;
00782  MSTAR[GAAS][1]=0.067; // Gamma-valley
00783  MSTAR[GAAS][2]=0.350; // L-valley
00784  MSTAR[GERMANIUM][1]=0.22;
00785  MSTAR[INSB][1]=0.013;
00786  MSTAR[INSB][2]=0.442;
00787  MSTAR[ALSB][1]=0.14;
00788  MSTAR[ALSB][2]=0.442;
00789  MSTAR[ALAS][1]=0.149;
00790  MSTAR[ALAS][2]=pow(1.456*pow(0.165,2.),1./3.);
00791  MSTAR[ALP][1]=0.166;
00792  MSTAR[ALP][2]=pow(1.556*pow(0.162,2.),1./3.);
00793  MSTAR[GAP][1]=0.122;
00794  MSTAR[GAP][2]=pow(1.498*pow(0.358,2.),1./3.);
00795  MSTAR[GASB][1]=0.048;
00796  MSTAR[GASB][2]=pow(1.4*pow(0.139,2.),1./3.);
00797  MSTAR[INAS][1]=0.031;
00798  MSTAR[INAS][2]=pow(1.590*pow(0.326,2.),1./3.);
00799  MSTAR[INP][1]=0.083;
00800  MSTAR[INP][2]=pow(1.893*pow(0.425,2.),1./3.);
00801  MSTAR[ALXINXSB][1]=XVAL[ALXINXSB]*(MSTAR[ALSB][1]+MSTAR[INSB][1]);
00802  MSTAR[ALXINXSB][2]=XVAL[ALXINXSB]*(MSTAR[ALSB][2]+MSTAR[INSB][2]);
00803  MSTAR[ALXIN1XSB][1]=XVAL[ALXIN1XSB]*MSTAR[ALSB][1]+(1.-XVAL[ALXIN1XSB])*MSTAR[INSB][1];
00804  MSTAR[ALXIN1XSB][2]=XVAL[ALXIN1XSB]*MSTAR[ALSB][2]+(1.-XVAL[ALXIN1XSB])*MSTAR[INSB][2];
00805 // non-parabolicity coefficient for Silicon
00806  alphaK[SILICON][1]=0.5;
00807 // non-parabolicity coefficient for Germanium
00808  alphaK[GERMANIUM][1]=0.65;
00809 // non-parabolicity coefficient for InSb in the GAMMA-valley
00810  alphaK[INSB][1]=pow(1.-MSTAR[INSB][1],2.)/EG[INSB];//5.59;
00811  printf("alphaK_gamma[InSb] = %g\n",alphaK[INSB][1]); 
00812 // non-parabolicity coefficient for InSb in the L-valley
00813  alphaK[INSB][2]=pow(1.-MSTAR[INSB][2],2.)/EG[INSB];//1.789;
00814  printf("alphaK_L[InSb]     = %g\n",alphaK[INSB][2]);
00815 // non-parabolicity coefficient for GaAs in the GAMMA-valley
00816  alphaK[GAAS][1]=pow(1.-MSTAR[GAAS][1],2.)/EG[GAAS];//0.611;
00817  printf("alphaK_gamma[GaAs] = %g\n",alphaK[GAAS][1]);
00818 // non-parabolicity coefficient for GaAs in the L-valley
00819  alphaK[GAAS][2]=pow(1.-MSTAR[GAAS][2],2.)/EG[GAAS];//0.242;
00820  printf("alphaK_L[GaAs]     = %g\n",alphaK[GAAS][2]);
00821 // non-parabolicity coefficient for AlSb in the GAMMA-valley
00822  alphaK[ALSB][1]=pow(1.-MSTAR[ALSB][1],2.)/EG[ALSB];//0.321;
00823  printf("alphaK_gamma[AlSb] = %g\n",alphaK[ALSB][1]);
00824 // non-parabolicity coefficient for AlSb in the L-valley
00825  alphaK[ALSB][2]=pow(1.-MSTAR[ALSB][2],2.)/EG[ALSB];//0.135;
00826  printf("alphaK_L[AlSb]     = %g\n",alphaK[ALSB][2]);
00827  for(index=ALAS;index<=INP;index++){
00828 // non-parabolicity coefficient in the GAMMA-valley
00829  alphaK[index][1]=pow(1.-MSTAR[index][1],2.)/EG[index];
00830  printf("alphaK_gamma[%d] = %g\n",index,alphaK[index][1]);
00831 // non-parabolicity coefficient in the L-valley
00832  alphaK[index][2]=pow(1.-MSTAR[index][2],2.)/EG[index];
00833  printf("alphaK_L[%d]     = %g\n",index,alphaK[index][2]);
00834  }
00835 // non-parabolicity coefficient for Al_x In_x Sb in the GAMMA-valley
00836  alphaK[ALXINXSB][1]=XVAL[ALXINXSB]*(alphaK[ALSB][1]+alphaK[INSB][1]);
00837 // non-parabolicity coefficient for Al_x In_x Sb in the L-valley
00838  alphaK[ALXINXSB][2]=XVAL[ALXINXSB]*(alphaK[ALSB][2]+alphaK[INSB][2]);
00839 // non-parabolicity coefficient for Al_x In_(1-x) Sb in the GAMMA-valley
00840  alphaK[ALXIN1XSB][1]=XVAL[ALXIN1XSB]*alphaK[ALSB][1]+(1.-XVAL[ALXIN1XSB])*alphaK[INSB][1];
00841 // non-parabolicity coefficient for Al_x In_(1-x) Sb in the L-valley
00842  alphaK[ALXIN1XSB][2]=XVAL[ALXIN1XSB]*alphaK[ALSB][2]+(1.-XVAL[ALXIN1XSB])*alphaK[INSB][2];
00843  printf("\n");
00844 // constant for the Impact-Ionization Keldysh model (1/sec)
00845  PII[SILICON]=6.80e14;
00846  PII[GERMANIUM]=2.0e12;
00847  PII[INSB]=2.0e12;//7.5e14;
00848  PII[GAAS]=2.5e15;
00849  PII[ALSB]=1.5e15;
00850  PII[ALAS]=1.5e15;
00851  PII[ALP]=1.5e15;
00852  PII[GAP]=2.5e14;
00853  PII[GASB]=1.5e15;
00854  PII[INAS]=7.5e14;
00855  PII[INP]=7.5e13;
00856  PII[ALXINXSB]=XVAL[ALXINXSB]*(PII[ALSB]+PII[INSB]);
00857  PII[ALXIN1XSB]=XVAL[ALXIN1XSB]*PII[ALSB]+(1.-XVAL[ALXIN1XSB])*PII[INSB];
00858 // Ionization threshold
00859  ETH[SILICON]=3.45;
00860  ETH[GERMANIUM]=EG[GERMANIUM];
00861  ETH[INSB]=0.036+EG[INSB];
00862  ETH[GAAS]=0.30+EG[GAAS];
00863  ETH[ALSB]=0.30+EG[ALSB];
00864  ETH[ALAS]=0.30+EG[ALAS];
00865  ETH[ALP]=0.30+EG[ALP];
00866  ETH[GAP]=0.10+EG[GAP];
00867  ETH[GASB]=0.30+EG[GASB];
00868  ETH[INAS]=0.03+EG[INAS];
00869  ETH[INP]=0.50+EG[INP];
00870  ETH[ALXINXSB]=XVAL[ALXINXSB]*(ETH[ALSB]+ETH[INSB]);
00871  ETH[ALXIN1XSB]=XVAL[ALXIN1XSB]*ETH[ALSB]+(1.-XVAL[ALXIN1XSB])*ETH[INSB];
00872 // ==============================
00873 // ==============================
00874 
00875 // definition of the neighbourhood table
00876   if(NHTFLAG==WRITE){
00877    printf("Computing the neighbourhood table...\n");
00878    neighbourhood_table();
00879    printf("Neighbourhood table calculated and saved.\n\n");
00880   }
00881 
00882 // reading the neighbourhood table
00883   if(NHTFLAG==READ){
00884    printf("Reading the neighbourhood table...\n");
00885    read_neighbourhood_table();
00886    printf("Neighbourhood table read.\n\n");
00887   }
00888 
00889 // various dynamical allocations
00890 // #include "headers/services/dynamical_allocations.h"
00891 
00892 // various parameters setup for montecarlo
00893   printf("\n\nSetting up the materials table...\n");
00894   for(index=0;index<NOAMTIA;index++) montecarlo_setup(index);
00895   printf("Materials table setted.\n");
00896 
00897 // simulated device configuration
00898   printf("\n\nSetting up the device...\n");
00899   device_setup();
00900   printf("Device setted.\n");
00901 
00902 // save_particles_mesh_format(0);
00903 // exit(0);
00904 
00905 // Initialise the arrays xi[][] and omega[]
00906   initialize_GAUSS();
00907 
00908 // Definition of all the **base_geo and **base_ref elements.
00909   def_base_all();
00910 
00911 // Definition of all the **d_base_geo and **d_base_ref elements.
00912   def_d_base_all();
00913 
00914 // Definition of all the **poids_K elements.
00915   def_global_weights_all();
00916 
00917 // definition of all components of ***inv_jac_K
00918   define_inverse_jacobian();
00919 
00920 // definition of the arrays ****d_base_K
00921   define_d_base_K();
00922 
00923 // every boundary which has not been specified
00924 // is considered to be of insulator type as default
00925 {
00926  int i;
00927  int ij[4];
00928  int j,iflag;
00929  for(i=0;i<Ng;i++)
00930   if(i_front[i]!=OHMIC && i_front[i]!=SCHOTTKY) i_front[i]=4;
00931  for(i=0;i<Ne;i++){
00932    iflag=0;
00933 //   printf("%d of %d\n",i,Ne);
00934    if(vois[0][i]==-1){ij[1]=1; ij[2]=2; ij[3]=3; iflag=1;}
00935    if(vois[1][i]==-1){ij[1]=0; ij[2]=2; ij[3]=3; iflag=1;}
00936    if(vois[2][i]==-1){ij[1]=1; ij[2]=0; ij[3]=3; iflag=1;}
00937    if(vois[3][i]==-1){ij[1]=1; ij[2]=2; ij[3]=0; iflag=1;}
00938    if(iflag==1) for(j=1;j<=3;j++){
00939 //    printf("j=%d %d\n",j,iij[j]);
00940     if(i_front[noeud_geo[ij[j]][i]-1]!=OHMIC &&
00941        i_front[noeud_geo[ij[j]][i]-1]!=SCHOTTKY)
00942        i_front[noeud_geo[ij[j]][i]-1]=INSULATOR;
00943    }
00944  }
00945 }
00946 
00947 // definition of the A matrix of the 3D Poisson related system
00948 // in a row-indexed sparse storage mode
00949   assemble_matrix_A();
00950 
00951 // definition of the b rhs of the 3D Poisson related system
00952   assemble_rhs_B();
00953 // {int i; for(i=1;i<=Ng;i++) printf("main b[%d]=%g\n",i,b[i]);}
00954 
00955 // resolution of 3D Poisson equation (finite element method)
00956 // (only for the applied electrostatic potential!)
00957   poisson3D(Vi,itol,tol,itmax);
00958   {int j; <