more fix on Ec/Ev.
[gss-tcad.git] / src / solver / initial.cc
blob4f5e466802e6e804a5252997be822df48df8936e
1 /*****************************************************************************/
2 /* 8888888 88888888 88888888 */
3 /* 8 8 8 */
4 /* 8 8 8 */
5 /* 8 88888888 88888888 */
6 /* 8 8888 8 8 */
7 /* 8 8 8 8 */
8 /* 888888 888888888 888888888 */
9 /* */
10 /* A Two-Dimensional General Purpose Semiconductor Simulator. */
11 /* */
12 /* GSS 0.4x */
13 /* Last update: Apr 21, 2006 */
14 /* */
15 /* Gong Ding */
16 /* gdiso@ustc.edu */
17 /* NINT, No.69 P.O.Box, Xi'an City, China */
18 /* */
19 /*****************************************************************************/
22 #include "cmdbuf.h"
23 #include "bsolver.h"
24 #include "log.h"
25 #include <string.h>
28 //simple error hanfle function
29 inline int read_config_err_handle(char *s)
31 gss_log.string_buf()<<s;
32 gss_log.record();
33 return 1;
36 /* ----------------------------------------------------------------------------
37 * BSolver::static_config: This function get global config data from CmdParseBuf
39 int BSolver::static_config(CmdBuf *cmdbuf)
41 pcmdbuf = cmdbuf;
42 //set default value
43 mesh_scale = 1e6;
44 Carrier = PN_Both;
45 LatticeTemp = 300;
46 DeviceDepth = 1.0;
48 //search the CmdParseBuf. setup global variables
49 for(pcmdbuf->cmd_search_begin();!pcmdbuf->cmd_search_end();)
51 if(pcmdbuf->is_current_cmd("SET")) //it is a set structure
53 list<Cmd>::iterator pcmd = pcmdbuf->get_current_cmd();
54 if(pcmd->is_arg_exist("latticetemp"))
55 LatticeTemp = pcmd->get_number("latticetemp",0,300.0);
56 if(pcmd->is_arg_exist("z.width"))
57 DeviceDepth = pcmd->get_number("z.width",0,1.0);
58 if(pcmd->is_arg_exist("dopingscale"))
59 mesh_scale = pow(pcmd->get_number("dopingscale",0,1e18),1.0/3);
60 if(pcmd->is_arg_exist("carrier"))
62 if(pcmd->is_arg_value("carrier","pn")) Carrier=PN_Both;
63 else if(pcmd->is_arg_value("carrier","p")) Carrier=P_Type;
64 else if(pcmd->is_arg_value("carrier","n")) Carrier=N_Type;
65 else {sprintf(log_buf,"line %d Set: Unrecognized carrier type!\n",pcmd->lineno);GSS_LOG();return 1;}
67 pcmdbuf->delete_current_cmd();
69 else
70 pcmdbuf->goto_next_cmd();
73 //scale variables
74 scale_unit.SetPhysicalUnitScale(mesh_scale);
75 DeviceDepth = DeviceDepth*scale_unit.s_micron;
76 LatticeTemp = LatticeTemp*scale_unit.s_kelvin;
77 set_mesh_scale(scale_unit.s_centimeter);
78 show_config_info();
80 //set voltage and current sources
81 if(init_esource(pcmdbuf->cmd_list)) return 1;
82 //set PMI
83 if(init_PMI_Semiconductor(pcmdbuf,PMIS_define)) return 1;
84 //set doping function
85 if(init_doping_func()) return 1;
87 //set initial grid
88 if(init_grid(pcmdbuf->cmd_list)) return 1;
92 gss_log.string_buf()<<"\n";
93 gss_log.record();
94 return 0;
98 /* ----------------------------------------------------------------------------
99 * BSolver::config_info: This function print global config data to screen
100 * mainly for debug
102 void BSolver::show_config_info()
105 gss_log.string_buf()<<"\n--------------------------------------------------\n";
106 gss_log.record();
107 switch(Carrier)
109 case N_Type: gss_log.string_buf()<<"carrier : n only\n";gss_log.record();break;
110 case P_Type: gss_log.string_buf()<<"carrier : p only\n";gss_log.record();break;
111 case PN_Both: gss_log.string_buf()<<"carrier : pn both\n";gss_log.record();break;
114 gss_log.string_buf()<<"device Z-width : "<<DeviceDepth/scale_unit.s_micron<< "um\n";
115 gss_log.record();
117 gss_log.string_buf()<<"lattice temprature : "<<LatticeTemp/scale_unit.s_kelvin<< "K\n";
118 gss_log.record();
121 /* ----------------------------------------------------------------------------
122 * BSolver::clear_data: This function delete solution data structure
124 void BSolver::clear_data()
126 if(zonedata.size()==0) return;
127 for(int i=0;i<zonedata.size();i++)
128 delete zonedata[i];
129 zonedata.clear();
132 BSolver::~BSolver()
134 clear_data();
135 for(int i=0;i<vsrc.size();i++)
136 delete vsrc[i];
137 for(int i=0;i<isrc.size();i++)
138 delete isrc[i];
139 for(int i=0;i<doping_func.size();i++)
140 delete doping_func[i];