Main Page | Directories | File List | File Members

save_VTK.h

Go to the documentation of this file.
00001 /*
00002    This file belongs to Aeneas. Aeneas is a GNU package released under GPL 3 license.
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  
00010    This program is free software; you can redistribute it and/or modify
00011    it under the terms of the GNU General Public License as published by
00012    the Free Software Foundation; either version 3, or (at your option)
00013    any later version.
00014 
00015    This program is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018    GNU General Public License for more details.
00019 
00020    You should have received a copy of the GNU General Public License
00021    along with this program. If not, see <http://www.gnu.org/licenses/>.
00022 */
00023 
00024 // created on : 17 june 2007, Siracusa, Jean Michel Sellier
00025 // Last modified : 02 august 2007, Siracusa, Jean Michel Sellier
00026 
00027 // This subroutine saves the computed electric field in VTK format file
00028 
00029 // The electrostatic potential is described in micron
00030 // the potential is saved on the nodes of the mesh
00031 
00032 // The electric field components are described in V/micron
00033 // The Ex, Ey and Ez component are saved on the nodes of the mesh
00034 
00035 void save_VTK(int num)
00036 {
00037  int i;
00038  FILE *fp;
00039  char s[200];
00040 
00041  printf("Saving the VTK format files... num = %d\n",num);
00042 
00043 // potential field
00044  sprintf(s,"potential/VTK_format/potential%d.vtk",num);
00045  if(num<100) sprintf(s,"potential/VTK_format/potential0%d.vtk",num);
00046  if(num<10)  sprintf(s,"potential/VTK_format/potential00%d.vtk",num);
00047 
00048  fp=fopen(s,"w");
00049  fprintf(fp,"# vtk DataFile Version 2.0\n");
00050  fprintf(fp,"potential field on every node of the mesh (scalar in Volt)\n");
00051  fprintf(fp,"ASCII\n");
00052  fprintf(fp,"DATASET UNSTRUCTURED_GRID\n");
00053  fprintf(fp,"POINTS %d float\n",Ng);
00054  for(i=0;i<Ng;i++) fprintf(fp,"%g %g %g\n",coord[0][i]*1.e6,
00055                                            coord[1][i]*1.e6,coord[2][i]*1.e6);
00056  fprintf(fp,"CELLS %d %d\n",Ne,Ne*5);
00057  for(i=0;i<Ne;i++) fprintf(fp,"4 %d %d %d %d\n",noeud_geo[0][i]-1,
00058                                                 noeud_geo[1][i]-1,
00059                                                 noeud_geo[2][i]-1,
00060                                                 noeud_geo[3][i]-1);
00061  fprintf(fp,"CELL_TYPES %d\n",Ne);
00062  for(i=0;i<Ne;i++) fprintf(fp,"10\n");
00063  fprintf(fp,"POINT_DATA %d\n",Ng);
00064  fprintf(fp,"SCALARS potential double 1\n");
00065  fprintf(fp,"LOOKUP_TABLE default\n");
00066  for(i=0;i<Ng;i++) fprintf(fp,"%g\n",V[i]);
00067  fclose(fp);
00068 
00069 // electric field (vector)
00070  sprintf(s,"E/VTK_format/Efield%d.vtk",num);
00071  if(num<100) sprintf(s,"E/VTK_format/Efield0%d.vtk",num);
00072  if(num<10)  sprintf(s,"E/VTK_format/Efield00%d.vtk",num);
00073 
00074  fp=fopen(s,"w");
00075  fprintf(fp,"# vtk DataFile Version 2.0\n");
00076  fprintf(fp,"potential field on every node of the mesh (scalar in Volt)\n");
00077  fprintf(fp,"ASCII\n");
00078  fprintf(fp,"DATASET UNSTRUCTURED_GRID\n");
00079  fprintf(fp,"POINTS %d float\n",Ng);
00080  for(i=0;i<Ng;i++) fprintf(fp,"%g %g %g\n",coord[0][i]*1.e6,
00081                                            coord[1][i]*1.e6,coord[2][i]*1.e6);
00082  fprintf(fp,"CELLS %d %d\n",Ne,Ne*5);
00083  for(i=0;i<Ne;i++) fprintf(fp,"4 %d %d %d %d\n",noeud_geo[0][i]-1,
00084                                                 noeud_geo[1][i]-1,
00085                                                 noeud_geo[2][i]-1,
00086                                                 noeud_geo[3][i]-1);
00087  fprintf(fp,"CELL_TYPES %d\n",Ne);
00088  for(i=0;i<Ne;i++) fprintf(fp,"10\n");
00089  fprintf(fp,"POINT_DATA %d\n",Ng);
00090  fprintf(fp,"VECTORS electric_field double\n");
00091  for(i=0;i<Ng;i++) fprintf(fp,"%g %g %g\n",Ex[i],Ey[i],Ez[i]);
00092  fclose(fp);
00093 
00094 // electron density
00095  sprintf(s,"e_density/VTK_format/e_density%d.vtk",num);
00096  if(num<100) sprintf(s,"e_density/VTK_format/e_density0%d.vtk",num);
00097  if(num<10)  sprintf(s,"e_density/VTK_format/e_density00%d.vtk",num);
00098 
00099  fp=fopen(s,"w");
00100  fprintf(fp,"# vtk DataFile Version 2.0\n");
00101  fprintf(fp,"potential field on every node of the mesh (scalar in Volt)\n");
00102  fprintf(fp,"ASCII\n");
00103  fprintf(fp,"DATASET UNSTRUCTURED_GRID\n");
00104  fprintf(fp,"POINTS %d float\n",Ng);
00105  for(i=0;i<Ng;i++) fprintf(fp,"%g %g %g\n",coord[0][i]*1.e6,
00106                                            coord[1][i]*1.e6,coord[2][i]*1.e6);
00107  fprintf(fp,"CELLS %d %d\n",Ne,Ne*5);
00108  for(i=0;i<Ne;i++) fprintf(fp,"4 %d %d %d %d\n",noeud_geo[0][i]-1,
00109                                                 noeud_geo[1][i]-1,
00110                                                 noeud_geo[2][i]-1,
00111                                                 noeud_geo[3][i]-1);
00112  fprintf(fp,"CELL_TYPES %d\n",Ne);
00113  for(i=0;i<Ne;i++) fprintf(fp,"10\n");
00114  fprintf(fp,"POINT_DATA %d\n",Ng);
00115  fprintf(fp,"SCALARS electron_density double 1\n");
00116  fprintf(fp,"LOOKUP_TABLE default\n");
00117  for(i=0;i<Ng;i++) fprintf(fp,"%g\n",NE[i]); // electron density in 1/m^3
00118  fclose(fp);
00119  
00120  if((it==number_of_steps-1) || (it==number_of_steps)){
00121 // electron velocity (vector)
00122    sprintf(s,"e_velocity/VTK_format/e_velocity%d.vtk",num);
00123    if(num<100) sprintf(s,"e_velocity/VTK_format/e_velocity0%d.vtk",num);
00124    if(num<10)  sprintf(s,"e_velocity/VTK_format/e_velocity00%d.vtk",num);
00125 
00126    fp=fopen(s,"w");
00127    fprintf(fp,"# vtk DataFile Version 2.0\n");
00128    fprintf(fp,"velocity field on every node of the mesh (vector)\n");
00129    fprintf(fp,"ASCII\n");
00130    fprintf(fp,"DATASET UNSTRUCTURED_GRID\n");
00131    fprintf(fp,"POINTS %d float\n",Ng);
00132    for(i=0;i<Ng;i++) fprintf(fp,"%g %g %g\n",coord[0][i]*1.e6,
00133                                              coord[1][i]*1.e6,coord[2][i]*1.e6);
00134    fprintf(fp,"CELLS %d %d\n",Ne,Ne*5);
00135    for(i=0;i<Ne;i++) fprintf(fp,"4 %d %d %d %d\n",noeud_geo[0][i]-1,
00136                                                   noeud_geo[1][i]-1,
00137                                                   noeud_geo[2][i]-1,
00138                                                   noeud_geo[3][i]-1);
00139    fprintf(fp,"CELL_TYPES %d\n",Ne);
00140    for(i=0;i<Ne;i++) fprintf(fp,"10\n");
00141    fprintf(fp,"POINT_DATA %d\n",Ng);
00142    fprintf(fp,"VECTORS electron_velocity double\n");
00143    for(i=0;i<Ng;i++) fprintf(fp,"%g %g %g\n",XVEL[i]/((double)MEAN),
00144                                              YVEL[i]/((double)MEAN),
00145                                              ZVEL[i]/((double)MEAN));
00146    fclose(fp);
00147 
00148 // electron current (vector)
00149    sprintf(s,"e_current/VTK_format/e_current%d.vtk",num);
00150    if(num<100) sprintf(s,"e_current/VTK_format/e_current0%d.vtk",num);
00151    if(num<10)  sprintf(s,"e_current/VTK_format/e_current00%d.vtk",num);
00152 
00153    fp=fopen(s,"w");
00154    fprintf(fp,"# vtk DataFile Version 2.0\n");
00155    fprintf(fp,"currents field on every node of the mesh (vector)\n");
00156    fprintf(fp,"ASCII\n");
00157    fprintf(fp,"DATASET UNSTRUCTURED_GRID\n");
00158    fprintf(fp,"POINTS %d float\n",Ng);
00159    for(i=0;i<Ng;i++) fprintf(fp,"%g %g %g\n",coord[0][i]*1.e6,
00160                                              coord[1][i]*1.e6,coord[2][i]*1.e6);
00161    fprintf(fp,"CELLS %d %d\n",Ne,Ne*5);
00162    for(i=0;i<Ne;i++) fprintf(fp,"4 %d %d %d %d\n",noeud_geo[0][i]-1,
00163                                                   noeud_geo[1][i]-1,
00164                                                   noeud_geo[2][i]-1,
00165                                                   noeud_geo[3][i]-1);
00166    fprintf(fp,"CELL_TYPES %d\n",Ne);
00167    for(i=0;i<Ne;i++) fprintf(fp,"10\n");
00168    fprintf(fp,"POINT_DATA %d\n",Ng);
00169    fprintf(fp,"VECTORS electron_velocity double\n");
00170    for(i=0;i<Ng;i++) fprintf(fp,"%g %g %g\n",-Q*NE[i]*XVEL[i]/((double)MEAN),
00171                                              -Q*NE[i]*YVEL[i]/((double)MEAN),
00172                                              -Q*NE[i]*ZVEL[i]/((double)MEAN));
00173    fclose(fp);
00174 
00175 // electron energy
00176    sprintf(s,"e_energy/VTK_format/e_energy%d.vtk",num);
00177    if(num<100) sprintf(s,"e_energy/VTK_format/e_energy0%d.vtk",num);
00178    if(num<10)  sprintf(s,"e_energy/VTK_format/e_energy00%d.vtk",num);
00179 
00180    fp=fopen(s,"w");
00181    fprintf(fp,"# vtk DataFile Version 2.0\n");
00182    fprintf(fp,"potential field on every node of the mesh (scalar in Volt)\n");
00183    fprintf(fp,"ASCII\n");
00184    fprintf(fp,"DATASET UNSTRUCTURED_GRID\n");
00185    fprintf(fp,"POINTS %d float\n",Ng);
00186    for(i=0;i<Ng;i++) fprintf(fp,"%g %g %g\n",coord[0][i]*1.e6,
00187                                              coord[1][i]*1.e6,coord[2][i]*1.e6);
00188    fprintf(fp,"CELLS %d %d\n",Ne,Ne*5);
00189    for(i=0;i<Ne;i++) fprintf(fp,"4 %d %d %d %d\n",noeud_geo[0][i]-1,
00190                                                   noeud_geo[1][i]-1,
00191                                                   noeud_geo[2][i]-1,
00192                                                   noeud_geo[3][i]-1);
00193    fprintf(fp,"CELL_TYPES %d\n",Ne);
00194    for(i=0;i<Ne;i++) fprintf(fp,"10\n");
00195    fprintf(fp,"POINT_DATA %d\n",Ng);
00196    fprintf(fp,"SCALARS electron_energy double 1\n");
00197    fprintf(fp,"LOOKUP_TABLE default\n");
00198    for(i=0;i<Ng;i++) fprintf(fp,"%g\n",ENEL[i]/((double)MEAN));
00199    fclose(fp);
00200  }
00201 }
00202 

© sourcejam.com 2005-2008