1 /*****************************************************************************/
2 /* 8888888 88888888 88888888 */
5 /* 8 88888888 88888888 */
8 /* 888888 888888888 888888888 */
10 /* A Two-Dimensional General Purpose Semiconductor Simulator. */
13 /* Last update: Nov 29, 2007 */
17 /* NINT, No.69 P.O.Box, Xi'an City, China */
19 /*****************************************************************************/
23 int BSolver::probe_open(int solver_type
)
25 for(int i
=0;i
<probe_define
.size();i
++)
27 BaseBC
* pbc
= bc
.Get_pointer(probe_define
[i
].bc_index
);
28 int node_num
=pbc
->psegment
->node_array
.size();
29 if(probe_define
[i
].Append
)
30 probe_define
[i
].pFile
= fopen(probe_define
[i
].ProbeFile
.c_str(),"a");
32 probe_define
[i
].pFile
= fopen(probe_define
[i
].ProbeFile
.c_str(),"w");
33 if(!probe_define
[i
].pFile
)
34 {sprintf(log_buf
,"I can't open file %s for writing!\n",probe_define
[i
].ProbeFile
.c_str());GSS_LOG();return 1;}
35 fprintf(probe_define
[i
].pFile
,"#Region: %s Segment: %s\n",probe_define
[i
].Region
.c_str(), probe_define
[i
].Segment
.c_str());
36 fprintf(probe_define
[i
].pFile
,"#%d\tX\tY\t\n",node_num
);
37 for(int p
=0;p
<node_num
;p
++)
39 int node
= pbc
->psegment
->node_array
[p
];
40 double x
= zone
[probe_define
[i
].zone_index
].danode
[node
].x
/scale_unit
.s_micron
;
41 double y
= zone
[probe_define
[i
].zone_index
].danode
[node
].y
/scale_unit
.s_micron
;
42 fprintf(probe_define
[i
].pFile
,"#%d\t%f\t%f\n",p
,x
,y
);
50 int BSolver::probe(int solver_type
, PetscScalar x
)
52 for(int i
=0;i
<probe_define
.size();i
++)
54 BaseBC
* pbc
= bc
.Get_pointer(probe_define
[i
].bc_index
);
55 int node_num
=pbc
->psegment
->node_array
.size();
57 if(!probe_define
[i
].flag
)
62 fprintf(probe_define
[i
].pFile
,"#DCSWEEP_VSCAN(V)\t[%s]\n",probe_define
[i
].VariableName
.c_str());break;
64 fprintf(probe_define
[i
].pFile
,"#DCSWEEP_ISCAN(mA)\t[%s]\n",probe_define
[i
].VariableName
.c_str());break;
66 fprintf(probe_define
[i
].pFile
,"#TRANSIENT(ps)\t[%s]\n",probe_define
[i
].VariableName
.c_str());break;
68 fprintf(probe_define
[i
].pFile
,"#EQUILIBRIUM\t[%s]\n",probe_define
[i
].VariableName
.c_str());break;
70 fprintf(probe_define
[i
].pFile
,"#STEADYSTATE\t[%s]\n",probe_define
[i
].VariableName
.c_str());break;
72 fprintf(probe_define
[i
].pFile
,"#[%s]\n",probe_define
[i
].VariableName
.c_str());break;
74 probe_define
[i
].flag
=true;
76 //write scan information
80 fprintf(probe_define
[i
].pFile
,"%e\t",double(x
)/scale_unit
.s_volt
);break;
82 fprintf(probe_define
[i
].pFile
,"%e\t",double(x
)/scale_unit
.s_mA
);break;
84 fprintf(probe_define
[i
].pFile
,"%e\t",double(x
));break;
86 //record data for semiconductor zone only
87 if( probe_define
[i
].Variable
==Doping
||
88 probe_define
[i
].Variable
==DopingNd
||
89 probe_define
[i
].Variable
==DopingNa
||
90 probe_define
[i
].Variable
==ElecDensity
||
91 probe_define
[i
].Variable
==HoleDensity
||
92 probe_define
[i
].Variable
==ElecTemp
||
93 probe_define
[i
].Variable
==HoleTemp
||
94 probe_define
[i
].Variable
==PhiP
||
95 probe_define
[i
].Variable
==PhiN
||
96 probe_define
[i
].Variable
==Phi_Intrinsic
||
97 probe_define
[i
].Variable
==QuantumEc
||
98 probe_define
[i
].Variable
==QuantumEv
||
99 probe_define
[i
].Variable
==OpticalEz
||
100 probe_define
[i
].Variable
==OpticalHz
||
101 probe_define
[i
].Variable
==OpticalG
)
103 if(zonedata
[probe_define
[i
].zone_index
]->material_type
== Semiconductor
)
105 SMCZone
*pzonedata
= dynamic_cast<SMCZone
*> (zonedata
[probe_define
[i
].zone_index
]);
106 for(int p
=0;p
<node_num
;p
++)
108 int node
= pbc
->psegment
->node_array
[p
];
109 switch(probe_define
[i
].Variable
)
112 fprintf(probe_define
[i
].pFile
,"%e\t",double(pzonedata
->aux
[node
].Nd
*pow(scale_unit
.s_centimeter
,3)));break;
114 fprintf(probe_define
[i
].pFile
,"%e\t",double(pzonedata
->aux
[node
].Na
*pow(scale_unit
.s_centimeter
,3)));break;
116 fprintf(probe_define
[i
].pFile
,"%e\t",double((pzonedata
->aux
[node
].Nd
-pzonedata
->aux
[node
].Na
)*pow(scale_unit
.s_centimeter
,3)));break;
118 fprintf(probe_define
[i
].pFile
,"%e\t",double(fabs(pzonedata
->fs
[node
].n
)*pow(scale_unit
.s_centimeter
,3)));break;
120 fprintf(probe_define
[i
].pFile
,"%e\t",double(fabs(pzonedata
->fs
[node
].p
)*pow(scale_unit
.s_centimeter
,3)));break;
122 fprintf(probe_define
[i
].pFile
,"%e\t",double(pzonedata
->fs
[node
].Tn
/scale_unit
.s_kelvin
));break;
124 fprintf(probe_define
[i
].pFile
,"%e\t",double(pzonedata
->fs
[node
].Tp
/scale_unit
.s_kelvin
));break;
126 fprintf(probe_define
[i
].pFile
,"%e\t",double(pzonedata
->aux
[node
].phi_intrinsic
/scale_unit
.s_volt
));break;
128 fprintf(probe_define
[i
].pFile
,"%e\t",double(pzonedata
->aux
[node
].phip
/scale_unit
.s_volt
));break;
130 fprintf(probe_define
[i
].pFile
,"%e\t",double(pzonedata
->aux
[node
].phin
/scale_unit
.s_volt
));break;
132 fprintf(probe_define
[i
].pFile
,"%e\t",double((pzonedata
->fs
[node
].Eqc
+pzonedata
->fs
[node
].P
+pzonedata
->aux
[node
].affinity
)/scale_unit
.s_volt
));break;
134 fprintf(probe_define
[i
].pFile
,"%e\t",double((pzonedata
->fs
[node
].Eqv
+pzonedata
->fs
[node
].P
+pzonedata
->aux
[node
].affinity
+pzonedata
->aux
[node
].Eg
)/scale_unit
.s_volt
));break;
136 fprintf(probe_define
[i
].pFile
,"%e\t",double(pzonedata
->aux
[node
].OpEz
/scale_unit
.s_volt
*scale_unit
.s_centimeter
));break;
138 fprintf(probe_define
[i
].pFile
,"%e\t",double(pzonedata
->aux
[node
].OpHz
/scale_unit
.s_A
*scale_unit
.s_centimeter
));break;
140 fprintf(probe_define
[i
].pFile
,"%e\t",double(pzonedata
->aux
[node
].OptG
*pow(scale_unit
.s_centimeter
,3)));break;
145 //record data for all zones
146 if( probe_define
[i
].Variable
==Potential
||
147 probe_define
[i
].Variable
==EFieldX
||
148 probe_define
[i
].Variable
==EFieldY
||
149 probe_define
[i
].Variable
==Temperature
)
151 if(zonedata
[probe_define
[i
].zone_index
]->material_type
== Semiconductor
)
153 SMCZone
*pzonedata
= dynamic_cast<SMCZone
*> (zonedata
[probe_define
[i
].zone_index
]);
154 for(int p
=0;p
<node_num
;p
++)
156 int node
= pbc
->psegment
->node_array
[p
];
157 switch(probe_define
[i
].Variable
)
160 fprintf(probe_define
[i
].pFile
,"%e\t",double(pzonedata
->fs
[node
].P
/scale_unit
.s_volt
));break;
162 fprintf(probe_define
[i
].pFile
,"%e\t",double(pzonedata
->aux
[node
].Ex
/scale_unit
.s_volt
*scale_unit
.s_centimeter
));break;
164 fprintf(probe_define
[i
].pFile
,"%e\t",double(pzonedata
->aux
[node
].Ey
/scale_unit
.s_volt
*scale_unit
.s_centimeter
));break;
166 fprintf(probe_define
[i
].pFile
,"%e\t",double(pzonedata
->fs
[node
].T
/scale_unit
.s_kelvin
));break;
171 if(zonedata
[probe_define
[i
].zone_index
]->material_type
== Insulator
)
173 ISZone
*pzonedata
= dynamic_cast<ISZone
*> (zonedata
[probe_define
[i
].zone_index
]);
174 for(int p
=0;p
<node_num
;p
++)
176 int node
= pbc
->psegment
->node_array
[p
];
177 switch(probe_define
[i
].Variable
)
180 fprintf(probe_define
[i
].pFile
,"%e\t",double(pzonedata
->fs
[node
].P
/scale_unit
.s_volt
));break;
182 fprintf(probe_define
[i
].pFile
,"%e\t",double(pzonedata
->aux
[node
].Ex
/scale_unit
.s_volt
*scale_unit
.s_centimeter
));break;
184 fprintf(probe_define
[i
].pFile
,"%e\t",double(pzonedata
->aux
[node
].Ey
/scale_unit
.s_volt
*scale_unit
.s_centimeter
));break;
186 fprintf(probe_define
[i
].pFile
,"%e\t",double(pzonedata
->fs
[node
].T
/scale_unit
.s_kelvin
));break;
191 if(zonedata
[probe_define
[i
].zone_index
]->material_type
== Conductor
)
193 ElZone
*pzonedata
= dynamic_cast<ElZone
*> (zonedata
[probe_define
[i
].zone_index
]);
194 for(int p
=0;p
<node_num
;p
++)
196 int node
= pbc
->psegment
->node_array
[p
];
197 switch(probe_define
[i
].Variable
)
200 fprintf(probe_define
[i
].pFile
,"%e\t",double(pzonedata
->fs
[node
].P
/scale_unit
.s_volt
));break;
202 fprintf(probe_define
[i
].pFile
,"%e\t",double(pzonedata
->aux
[node
].Ex
/scale_unit
.s_volt
*scale_unit
.s_centimeter
));break;
204 fprintf(probe_define
[i
].pFile
,"%e\t",double(pzonedata
->aux
[node
].Ey
/scale_unit
.s_volt
*scale_unit
.s_centimeter
));break;
206 fprintf(probe_define
[i
].pFile
,"%e\t",double(pzonedata
->fs
[node
].T
/scale_unit
.s_kelvin
));break;
212 fprintf(probe_define
[i
].pFile
,"\n");
213 fflush(probe_define
[i
].pFile
);
219 int BSolver::probe_close()
221 for(int i
=0;i
<probe_define
.size();i
++)
223 if(probe_define
[i
].pFile
)
224 fclose(probe_define
[i
].pFile
);
226 probe_define
.clear();