1 /*****************************************************************************/
2 /* 8888888 88888888 88888888 */
5 /* 8 88888888 88888888 */
8 /* 888888 888888888 888888888 */
10 /* A Two-Dimensional General Purpose Semiconductor Simulator. */
13 /* Last update: Oct 30, 2006 */
17 /* NINT, No.69 P.O.Box, Xi'an City, China */
19 /*****************************************************************************/
27 int BSolver::vtk_display_data(PlotDefine
& plot_define
)
29 // This is the child process.
31 char *vtk_wish
= new char [strlen(getenv("GSS_DIR"))+32];
32 char *vtk_script
= new char [strlen(getenv("GSS_DIR"))+32];
33 sprintf(vtk_wish
,"%s/bin/vtk",getenv("GSS_DIR"));
34 sprintf(vtk_script
,"%s/bin/vtk_plot.tcl",getenv("GSS_DIR"));
36 if ( plot_define
.Variable
== Potential
)
38 sprintf(filename
,"data_%s.vtk","Potential");
39 vtk_output_file(filename
);
40 if(execl(vtk_wish
, "vtk",vtk_script
,filename
,"Potential",0)==-1)
41 { gss_log
.string_buf()<<"VTK plot error!"; gss_log
.record();}
43 else if (plot_define
.Variable
== DopingNa
)
45 sprintf(filename
,"data_%s.vtk","Na");
46 vtk_output_file(filename
);
47 if(execl(vtk_wish
, "vtk",vtk_script
,filename
,"Na",0)==-1)
48 { gss_log
.string_buf()<<"VTK plot error!"; gss_log
.record();}
50 else if (plot_define
.Variable
== DopingNd
)
52 sprintf(filename
,"data_%s.vtk","Nd");
53 vtk_output_file(filename
);
54 if(execl(vtk_wish
, "vtk",vtk_script
,filename
,"Nd",0)==-1)
55 { gss_log
.string_buf()<<"VTK plot error!"; gss_log
.record();}
57 else if (plot_define
.Variable
== ElecDensity
)
59 sprintf(filename
,"data_%s.vtk","ElecDensity");
60 vtk_output_file(filename
);
61 if(execl(vtk_wish
, "vtk",vtk_script
,filename
,"ElecDensity",0)==-1)
62 { gss_log
.string_buf()<<"VTK plot error!"; gss_log
.record();}
64 else if (plot_define
.Variable
== HoleDensity
)
66 sprintf(filename
,"data_%s.vtk","HoleDensity");
67 vtk_output_file(filename
);
68 if(execl(vtk_wish
, "vtk",vtk_script
,filename
,"HoleDensity",0)==-1)
69 { gss_log
.string_buf()<<"VTK plot error!"; gss_log
.record();}
71 else if (plot_define
.Variable
== Temperature
)
73 sprintf(filename
,"data_%s.vtk","Temperature");
74 vtk_output_file(filename
);
75 if(execl(vtk_wish
, "vtk",vtk_script
,filename
,"Temperature",0)==-1)
76 { gss_log
.string_buf()<<"VTK plot error!"; gss_log
.record();}
78 else if (plot_define
.Variable
== OpticalEz
)
80 sprintf(filename
,"data_%s.vtk","OpticalEz");
81 vtk_output_file(filename
);
82 if(execl(vtk_wish
, "vtk",vtk_script
,filename
,"OpticalEz",0)==-1)
83 { gss_log
.string_buf()<<"VTK plot error!"; gss_log
.record();}
92 int BSolver::vtk_output_file(char *filename
)
95 fp
= fopen(filename
,"w");
98 sprintf(log_buf
,"Error, can't open file for vtk data output\n");
103 fprintf(fp
,"# vtk DataFile Version 2.0\n");
104 fprintf(fp
,"GSS data file\n");
105 fprintf(fp
,"ASCII\n");
106 fprintf(fp
,"DATASET UNSTRUCTURED_GRID\n\n");
107 fprintf(fp
,"POINTS %d double\n",gnode
.size());
108 for(int i
=0;i
<gnode
.size();i
++)
109 fprintf(fp
,"%e %e %lf\n",gnode
[i
].x
/scale_unit
.s_micron
,gnode
[i
].y
/scale_unit
.s_micron
,0.0);
110 fprintf(fp
,"\nCELLS %d %d\n",gtri
.size(),4*gtri
.size());
111 for(int i
=0;i
<gtri
.size();i
++)
112 fprintf(fp
,"%d %d %d %d\n",3,gtri
[i
].g_node
[0],gtri
[i
].g_node
[1],gtri
[i
].g_node
[2]);
113 fprintf(fp
,"CELL_TYPES %d\n",gtri
.size());
114 for(int i
=0;i
<gtri
.size();i
++)
115 fprintf(fp
,"%d\n",5);
118 fprintf(fp
,"\nPOINT_DATA %d\n",gnode
.size());
120 fprintf(fp
,"SCALARS Potential double 1\n");
121 fprintf(fp
,"LOOKUP_TABLE default\n");
122 for(int i
=0;i
<gnode
.size();i
++)
124 int zone_index
= gnode
[i
].zone_index
;
125 int local_index
= gnode
[i
].local_index
;
126 if(zonedata
[zone_index
]->material_type
== Semiconductor
)
128 SMCZone
*pzonedata
= dynamic_cast< SMCZone
* >(zonedata
[zone_index
]);
129 fprintf(fp
,"%e\n",double(pzonedata
->fs
[local_index
].P
/scale_unit
.s_volt
));
131 else if(zonedata
[zone_index
]->material_type
== Insulator
)
133 ISZone
*pzonedata
= dynamic_cast< ISZone
* >(zonedata
[zone_index
]);
134 fprintf(fp
,"%e\n",double(pzonedata
->fs
[local_index
].P
/scale_unit
.s_volt
));
136 else if(zonedata
[zone_index
]->material_type
== Conductor
)
138 ElZone
*pzonedata
= dynamic_cast< ElZone
* >(zonedata
[zone_index
]);
139 fprintf(fp
,"%e\n",double(pzonedata
->fs
[local_index
].P
/scale_unit
.s_volt
));
142 fprintf(fp
,"%e\n",0.0);
145 fprintf(fp
,"SCALARS ElecDensity double 1\n");
146 fprintf(fp
,"LOOKUP_TABLE default\n");
147 for(int i
=0;i
<gnode
.size();i
++)
149 int zone_index
= gnode
[i
].zone_index
;
150 int local_index
= gnode
[i
].local_index
;
151 if(zonedata
[zone_index
]->material_type
== Semiconductor
)
153 SMCZone
*pzonedata
= dynamic_cast< SMCZone
* >(zonedata
[zone_index
]);
154 fprintf(fp
,"%e\n",double(pzonedata
->fs
[local_index
].n
*pow(scale_unit
.s_centimeter
,3)));
157 fprintf(fp
,"%e\n",0.0);
160 fprintf(fp
,"SCALARS HoleDensity double 1\n");
161 fprintf(fp
,"LOOKUP_TABLE default\n");
162 for(int i
=0;i
<gnode
.size();i
++)
164 int zone_index
= gnode
[i
].zone_index
;
165 int local_index
= gnode
[i
].local_index
;
166 if(zonedata
[zone_index
]->material_type
== Semiconductor
)
168 SMCZone
*pzonedata
= dynamic_cast< SMCZone
* >(zonedata
[zone_index
]);
169 fprintf(fp
,"%e\n",double(pzonedata
->fs
[local_index
].p
*pow(scale_unit
.s_centimeter
,3)));
172 fprintf(fp
,"%e\n",0.0);
176 fprintf(fp
,"SCALARS Nd double 1\n");
177 fprintf(fp
,"LOOKUP_TABLE default\n");
178 for(int i
=0;i
<gnode
.size();i
++)
180 int zone_index
= gnode
[i
].zone_index
;
181 int local_index
= gnode
[i
].local_index
;
182 if(zonedata
[zone_index
]->material_type
== Semiconductor
)
184 SMCZone
*pzonedata
= dynamic_cast< SMCZone
* >(zonedata
[zone_index
]);
185 fprintf(fp
,"%e\n",double(pzonedata
->aux
[local_index
].Nd
*pow(scale_unit
.s_centimeter
,3)));
188 fprintf(fp
,"%e\n",0.0);
191 fprintf(fp
,"SCALARS Na double 1\n");
192 fprintf(fp
,"LOOKUP_TABLE default\n");
193 for(int i
=0;i
<gnode
.size();i
++)
195 int zone_index
= gnode
[i
].zone_index
;
196 int local_index
= gnode
[i
].local_index
;
197 if(zonedata
[zone_index
]->material_type
== Semiconductor
)
199 SMCZone
*pzonedata
= dynamic_cast< SMCZone
* >(zonedata
[zone_index
]);
200 fprintf(fp
,"%e\n",double(pzonedata
->aux
[local_index
].Na
*pow(scale_unit
.s_centimeter
,3)));
203 fprintf(fp
,"%e\n",0.0);
207 fprintf(fp
,"SCALARS Temperature double 1\n");
208 fprintf(fp
,"LOOKUP_TABLE default\n");
209 for(int i
=0;i
<gnode
.size();i
++)
211 int zone_index
= gnode
[i
].zone_index
;
212 int local_index
= gnode
[i
].local_index
;
213 if(zonedata
[zone_index
]->material_type
== Semiconductor
)
215 SMCZone
*pzonedata
= dynamic_cast< SMCZone
* >(zonedata
[zone_index
]);
216 fprintf(fp
,"%e\n",double(pzonedata
->fs
[local_index
].T
/scale_unit
.s_kelvin
));
218 else if(zonedata
[zone_index
]->material_type
== Insulator
)
220 ISZone
*pzonedata
= dynamic_cast< ISZone
* >(zonedata
[zone_index
]);
221 fprintf(fp
,"%e\n",double(pzonedata
->fs
[local_index
].T
/scale_unit
.s_kelvin
));
223 else if(zonedata
[zone_index
]->material_type
== Conductor
)
225 ElZone
*pzonedata
= dynamic_cast< ElZone
* >(zonedata
[zone_index
]);
226 fprintf(fp
,"%e\n",double(pzonedata
->fs
[local_index
].T
/scale_unit
.s_kelvin
));
229 fprintf(fp
,"%e\n",0.0);
232 fprintf(fp
,"SCALARS opticalEz double 1\n");
233 fprintf(fp
,"LOOKUP_TABLE default\n");
234 for(int i
=0;i
<gnode
.size();i
++)
236 int zone_index
= gnode
[i
].zone_index
;
237 int local_index
= gnode
[i
].local_index
;
238 if(zonedata
[zone_index
]->material_type
== Semiconductor
)
240 SMCZone
*pzonedata
= dynamic_cast< SMCZone
* >(zonedata
[zone_index
]);
241 fprintf(fp
,"%e\n",double(pzonedata
->aux
[local_index
].OpEz
/scale_unit
.s_volt
*scale_unit
.s_centimeter
));
243 else if(zonedata
[zone_index
]->material_type
== Insulator
)
245 ISZone
*pzonedata
= dynamic_cast< ISZone
* >(zonedata
[zone_index
]);
246 fprintf(fp
,"%e\n",double(pzonedata
->aux
[local_index
].OpEz
/scale_unit
.s_volt
*scale_unit
.s_centimeter
));
248 else if(zonedata
[zone_index
]->material_type
== Conductor
)
250 ElZone
*pzonedata
= dynamic_cast< ElZone
* >(zonedata
[zone_index
]);
251 fprintf(fp
,"%e\n",double(pzonedata
->aux
[local_index
].OpEz
/scale_unit
.s_volt
*scale_unit
.s_centimeter
));
253 else if(zonedata
[zone_index
]->material_type
== Vacuum
)
255 VacuumZone
*pzonedata
= dynamic_cast< VacuumZone
* >(zonedata
[zone_index
]);
256 fprintf(fp
,"%e\n",double(pzonedata
->aux
[local_index
].OpEz
/scale_unit
.s_volt
*scale_unit
.s_centimeter
));
258 else if(zonedata
[zone_index
]->material_type
== PML
)
260 PMLZone
*pzonedata
= dynamic_cast< PMLZone
* >(zonedata
[zone_index
]);
261 fprintf(fp
,"%e\n",double(pzonedata
->aux
[local_index
].OpEz
/scale_unit
.s_volt
*scale_unit
.s_centimeter
));
264 fprintf(fp
,"%e\n",0.0);
267 fprintf(fp
,"SCALARS OptG double 1\n");
268 fprintf(fp
,"LOOKUP_TABLE default\n");
269 for(int i
=0;i
<gnode
.size();i
++)
271 int zone_index
= gnode
[i
].zone_index
;
272 int local_index
= gnode
[i
].local_index
;
273 if(zonedata
[zone_index
]->material_type
== Semiconductor
)
275 SMCZone
*pzonedata
= dynamic_cast< SMCZone
* >(zonedata
[zone_index
]);
276 fprintf(fp
,"%e\n",double(pzonedata
->aux
[local_index
].OptG
*pow(scale_unit
.s_centimeter
,3)*scale_unit
.s_second
));
279 fprintf(fp
,"%e\n",0.0);
282 fprintf(fp
,"SCALARS opticalHz double 1\n");
283 fprintf(fp
,"LOOKUP_TABLE default\n");
284 for(int i
=0;i
<gnode
.size();i
++)
286 int zone_index
= gnode
[i
].zone_index
;
287 int local_index
= gnode
[i
].local_index
;
288 if(zonedata
[zone_index
]->material_type
== Semiconductor
)
290 SMCZone
*pzonedata
= dynamic_cast< SMCZone
* >(zonedata
[zone_index
]);
291 fprintf(fp
,"%e\n",double(pzonedata
->aux
[local_index
].OpHz
/scale_unit
.s_A
*scale_unit
.s_centimeter
));
293 else if(zonedata
[zone_index
]->material_type
== Insulator
)
295 ISZone
*pzonedata
= dynamic_cast< ISZone
* >(zonedata
[zone_index
]);
296 fprintf(fp
,"%e\n",double(pzonedata
->aux
[local_index
].OpHz
/scale_unit
.s_A
*scale_unit
.s_centimeter
));
298 else if(zonedata
[zone_index
]->material_type
== Conductor
)
300 ElZone
*pzonedata
= dynamic_cast< ElZone
* >(zonedata
[zone_index
]);
301 fprintf(fp
,"%e\n",double(pzonedata
->aux
[local_index
].OpHz
/scale_unit
.s_A
*scale_unit
.s_centimeter
));
303 else if(zonedata
[zone_index
]->material_type
== Vacuum
)
305 VacuumZone
*pzonedata
= dynamic_cast< VacuumZone
* >(zonedata
[zone_index
]);
306 fprintf(fp
,"%e\n",double(pzonedata
->aux
[local_index
].OpHz
/scale_unit
.s_A
*scale_unit
.s_centimeter
));
308 else if(zonedata
[zone_index
]->material_type
== PML
)
310 PMLZone
*pzonedata
= dynamic_cast< PMLZone
* >(zonedata
[zone_index
]);
311 fprintf(fp
,"%e\n",double(pzonedata
->aux
[local_index
].OpHz
/scale_unit
.s_A
*scale_unit
.s_centimeter
));
315 fprintf(fp
,"VECTORS EField double \n");
316 for(int i
=0;i
<gnode
.size();i
++)
318 int zone_index
= gnode
[i
].zone_index
;
319 int local_index
= gnode
[i
].local_index
;
320 if(zonedata
[zone_index
]->material_type
== Semiconductor
)
322 SMCZone
*pzonedata
= dynamic_cast< SMCZone
* >(zonedata
[zone_index
]);
323 fprintf(fp
,"%e %e 0\n",double(pzonedata
->aux
[local_index
].Ex
), double(pzonedata
->aux
[local_index
].Ey
));
325 else if(zonedata
[zone_index
]->material_type
== Insulator
)
327 ISZone
*pzonedata
= dynamic_cast< ISZone
* >(zonedata
[zone_index
]);
328 fprintf(fp
,"%e %e 0\n",double(pzonedata
->aux
[local_index
].Ex
), double(pzonedata
->aux
[local_index
].Ey
));
331 fprintf(fp
,"0 0 0\n");