Main Page | Directories | File List | File Members

save_particles_Point3D_format.h

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 // Created on : 17 june 2007, Siracusa, Jean Michel Sellier
00026 // Last modified : 16 september 2007, Siracusa, Jean Michel Sellier
00027 
00028 // save the position of all particles in Point3D format
00029 
00030 // this is the format :
00031 // # variable_name x y z
00032 // v(1)      x(1)      y(1)      z(1)
00033 // v(2)      x(2)      y(2)      z(2)
00034 // ...
00035 // v(i)      x(i)      y(i)      z(i)
00036 // ...
00037 // v(INUM-1) x(INUM-1) y(INUM-1) z(INUM-1)
00038 // v(INUM)   x(INUM)   y(INUM)   z(INUM)
00039 
00040 void save_particles_Point3D_format(int num)
00041 {
00042  int i,n;
00043  FILE *fp1, *fp2, *fp3;
00044  char s1[180], s2[180], s3[180];
00045 
00046  sprintf(s1,"particles/energy_Point3D_format/particles_ener%d.3d",num);
00047  if(num<100) sprintf(s1,"particles/energy_Point3D_format/particles_ener0%d.3d",num); 
00048  if(num<10)  sprintf(s1,"particles/energy_Point3D_format/particles_ener00%d.3d",num);
00049 
00050  sprintf(s2,"particles/potential_Point3D_format/particles_pot%d.3d",num);
00051  if(num<100) sprintf(s2,"particles/potential_Point3D_format/particles_pot0%d.3d",num);
00052  if(num<10)  sprintf(s2,"particles/potential_Point3D_format/particles_pot00%d.3d",num);
00053 
00054  sprintf(s3,"particles/position_Point3D_format/particles_pos%d.3d",num);
00055  if(num<100) sprintf(s3,"particles/position_Point3D_format/particles_pos0%d.3d",num);
00056  if(num<10)  sprintf(s3,"particles/position_Point3D_format/particles_pos00%d.3d",num);
00057 
00058  printf("Saving %d particles datas in Point3D format... num = %d\n",INUM,num);
00059 
00060  fp1=fopen(s1,"w"); 
00061  if(fp1==NULL){
00062     printf("save_particles_Point3D : impossible to open the fp1 output file!\n");
00063     exit(0);
00064  }
00065  fp2=fopen(s2,"w");
00066  if(fp2==NULL){
00067     printf("save_particles_Point3D : impossible to open the fp2 output file!\n");
00068     exit(0);
00069  }
00070  fp3=fopen(s3,"w");
00071  if(fp3==NULL){
00072     printf("save_particles_Point3D : impossible to open the fp3 output file!\n");
00073     exit(0);
00074  }
00075 
00076  fprintf(fp1,"# x y z energy\n");
00077  fprintf(fp2,"# x y z potential\n");
00078  fprintf(fp3,"# x y z nomeaning\n");
00079 
00080 // printf("INUM = %d\n",INUM);
00081  
00082  for(n=1;n<=INUM;n++){
00083 //        printf("n = %d\n",n);
00084    int iv;
00085    double x,y,z;
00086    double energy=0., potential;
00087    double thesquareroot, ksquared;
00088    iv=(int) P[n][0];
00089    i=(int) P[n][9];
00090    x=0.25*(P[n][5]*coord[0][noeud_geo[0][i]-1]
00091           +P[n][6]*coord[0][noeud_geo[1][i]-1]
00092           +P[n][7]*coord[0][noeud_geo[2][i]-1]
00093           +P[n][8]*coord[0][noeud_geo[3][i]-1]);
00094    y=0.25*(P[n][5]*coord[1][noeud_geo[0][i]-1]
00095           +P[n][6]*coord[1][noeud_geo[1][i]-1]
00096           +P[n][7]*coord[1][noeud_geo[2][i]-1]
00097           +P[n][8]*coord[1][noeud_geo[3][i]-1]);
00098    z=0.25*(P[n][5]*coord[2][noeud_geo[0][i]-1]
00099           +P[n][6]*coord[2][noeud_geo[1][i]-1]
00100           +P[n][7]*coord[2][noeud_geo[2][i]-1]
00101           +P[n][8]*coord[2][noeud_geo[3][i]-1]);
00102    potential=0.25*(V[noeud_geo[0][i]-1]+V[noeud_geo[1][i]-1]+
00103                    V[noeud_geo[2][i]-1]+V[noeud_geo[3][i]-1]);
00104    ksquared=P[n][1]*P[n][1]+P[n][2]*P[n][2]+P[n][3]*P[n][3];
00105    if(i_dom[i]!=SIO2){
00106      thesquareroot=sqrt(1.+4.*alphaK[i_dom[i]][iv]*HHM[i_dom[i]][iv]*ksquared);
00107      energy=(thesquareroot-1.)/(2.*alphaK[i_dom[i]][iv]);
00108    }
00109    fprintf(fp1,"%f %f %f %g\n",x*1.e6,y*1.e6,z*1.e6,energy);
00110    fprintf(fp2,"%f %f %f %g\n",x*1.e6,y*1.e6,z*1.e6,potential);
00111    fprintf(fp3,"%f %f %f  1\n",x*1.e6,y*1.e6,z*1.e6);
00112  }
00113  fclose(fp1);    
00114  fclose(fp2);
00115  fclose(fp3);
00116 }

© sourcejam.com 2005-2008