-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathQSdiode_common.py
More file actions
208 lines (177 loc) · 7.87 KB
/
QSdiode_common.py
File metadata and controls
208 lines (177 loc) · 7.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# Copyright 2013 Devsim LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from devsim import *
from QSsimple_physics import *
#####
# dio1
#
# Make doping a step function
# print dat to text file for viewing in grace
# verify currents analytically
# in dio2 add recombination
#
def CreateMesh(device, region, Length, refinescale):
'''
Meshing
'''
create_1d_mesh(mesh="dio")
add_1d_mesh_line(mesh="dio", pos=0, ps=refinescale*1e2, tag="top")
add_1d_mesh_line(mesh="dio", pos=Length/2, ps=refinescale, tag="mid")
add_1d_mesh_line(mesh="dio", pos=Length, ps=refinescale*1e2, tag="bot")
add_1d_contact (mesh="dio", name="top", tag="top", material="metal")
add_1d_contact (mesh="dio", name="bot", tag="bot", material="metal")
add_1d_region (mesh="dio", material="Si", region=region, tag1="top", tag2="bot")
finalize_mesh(mesh="dio")
create_device(mesh="dio", device=device)
# this is the mesh for the ssac device
# TODO: use CreateMesh and update regressions
def CreateMesh2(device, region):
create_1d_mesh(mesh="dio")
add_1d_mesh_line(mesh="dio", pos=0, ps=1e-7, tag="top")
add_1d_mesh_line(mesh="dio", pos=0.5e-5, ps=1e-8, tag="mid")
add_1d_mesh_line(mesh="dio", pos=1e-5, ps=1e-7, tag="bot")
add_1d_contact(mesh="dio", name="top", tag="top", material="metal")
add_1d_contact(mesh="dio", name="bot", tag="bot", material="metal")
add_1d_region(mesh="dio", material="Si", region=region, tag1="top", tag2="bot")
finalize_mesh(mesh="dio")
create_device(mesh="dio", device=device)
def Create2DMesh(device, region):
create_2d_mesh(mesh="dio")
add_2d_mesh_line(mesh="dio", dir="x", pos=0, ps=1e-6)
add_2d_mesh_line(mesh="dio", dir="x", pos=0.5e-5, ps=1e-8)
add_2d_mesh_line(mesh="dio", dir="x", pos=1e-5, ps=1e-6)
add_2d_mesh_line(mesh="dio", dir="y", pos=0, ps=1e-6)
add_2d_mesh_line(mesh="dio", dir="y", pos=1e-5, ps=1e-6)
add_2d_mesh_line(mesh="dio", dir="x", pos=-1e-8, ps=1e-8)
add_2d_mesh_line(mesh="dio", dir="x", pos=1.001e-5, ps=1e-8)
add_2d_region(mesh="dio", material="Si", region=region)
add_2d_region(mesh="dio", material="Si", region="air1", xl=-1e-8, xh=0)
add_2d_region(mesh="dio", material="Si", region="air2", xl=1.0e-5, xh=1.001e-5)
add_2d_contact(mesh="dio", name="top", material="metal", region=region, yl=0.8e-5, yh=1e-5, xl=0, xh=0, bloat=1e-10)
add_2d_contact(mesh="dio", name="bot", material="metal", region=region, xl=1e-5, xh=1e-5, bloat=1e-10)
finalize_mesh(mesh="dio")
create_device(mesh="dio", device=device)
def Create2DGmshMesh(device, region):
#this reads in the gmsh format
create_gmsh_mesh (mesh="diode2d", file="gmsh_diode2d.msh")
add_gmsh_region (mesh="diode2d", gmsh_name="Bulk", region=region, material="Silicon")
add_gmsh_contact (mesh="diode2d", gmsh_name="Base", region=region, material="metal", name="top")
add_gmsh_contact (mesh="diode2d", gmsh_name="Emitter", region=region, material="metal", name="bot")
finalize_mesh (mesh="diode2d")
create_device (mesh="diode2d", device=device)
def Create3DGmshMesh(device, region):
#this reads in the gmsh format
create_gmsh_mesh (mesh="diode3d", file="gmsh_diode3d.msh")
add_gmsh_region (mesh="diode3d", gmsh_name="Bulk", region=region, material="Silicon")
add_gmsh_contact (mesh="diode3d", gmsh_name="Base", region=region, material="metal", name="top")
add_gmsh_contact (mesh="diode3d", gmsh_name="Emitter", region=region, material="metal", name="bot")
finalize_mesh (mesh="diode3d")
create_device (mesh="diode3d", device=device)
def SetParameters(device, region):
'''
Set parameters for 300 K
'''
SetCentiMeterSiliconParameters(device, region, 300)
def SetNetDoping(device, region, DonorDoping=1e18, AccepterDoping=1e18, Length=1e-5):
'''
NetDoping
'''
CreateNodeModel(device, region, "Acceptors", "%e*step(%e/2-x)"%(DonorDoping,Length))
CreateNodeModel(device, region, "Donors", "%e*step(x-%e/2)"%(AccepterDoping,Length))
CreateNodeModel(device, region, "NetDoping", "Donors-Acceptors")
def InitialSolution(device, region, circuit_contacts=None):
# Create Potential, Potential@n0, Potential@n1
CreateSolution(device, region, "Potential")
# Create potential only physical models
CreateSiliconPotentialOnly(device, region)
# Set up the contacts applying a bias
for i in get_contact_list(device=device):
if circuit_contacts and i in circuit_contacts:
CreateSiliconPotentialOnlyContact(device, region, i, True)
else:
###print "FIX THIS"
### it is more correct for the bias to be 0, and it looks like there is side effects
set_parameter(device=device, name=GetContactBiasName(i), value=0.0)
CreateSiliconPotentialOnlyContact(device, region, i)
def DriftDiffusionInitialSolution(device, region, circuit_contacts=None):
####
#### drift diffusion solution variables
####
CreateSolution(device, region, "Electrons")
CreateSolution(device, region, "Holes")
####
#### create initial guess from dc only solution
####
set_node_values(device=device, region=region, name="Electrons", init_from="IntrinsicElectrons")
set_node_values(device=device, region=region, name="Holes", init_from="IntrinsicHoles")
###
### Set up equations
###
CreateSiliconDriftDiffusion(device, region)
for i in get_contact_list(device=device):
if circuit_contacts and i in circuit_contacts:
CreateSiliconDriftDiffusionAtContact(device, region, i, True)
else:
CreateSiliconDriftDiffusionAtContact(device, region, i)
#####
##### Ramp the bias to 0.5 Volts
#####
#v = 0.0
#while v < 0.51:
# set_parameter(device=device, name=GetContactBiasName("top"), value=v)
# solve(type="dc", absolute_error=1e10, relative_error=1e-10, maximum_iterations=30)
# PrintCurrents(device, "top")
# PrintCurrents(device, "bot")
# v += 0.1
#
#write_devices(file="diode_1d.dat", type="tecplot")
##import matplotlib
##import matplotlib.pyplot
##x=get_node_model_values(device=device, region=region, name="x")
##ymax = 10
##ymin = 10
##fields = ("Electrons", "Holes", "Donors", "Acceptors")
##for i in fields:
## y=get_node_model_values(device=device, region=region, name=i)
## if (max(y) > ymax):
## ymax = max(y)
## matplotlib.pyplot.semilogy(x, y)
##matplotlib.pyplot.xlabel('x (cm)')
##matplotlib.pyplot.ylabel('Density (#/cm^3)')
##matplotlib.pyplot.legend(fields)
##ymax *= 10
##matplotlib.pyplot.axis([min(x), max(x), ymin, ymax])
##matplotlib.pyplot.savefig("diode_1d_density.eps")
##
##matplotlib.pyplot.clf()
##edge_average_model(device=device, region=region, node_model="x", edge_model="xmid")
##xmid=get_edge_model_values(device=device, region=region, name="xmid")
##efields = ("ElectronCurrent", "HoleCurrent", )
##y=get_edge_model_values(device=device, region=region, name="ElectronCurrent")
##ymin=min(y)
##ymax=max(y)
##for i in efields:
## y=get_edge_model_values(device=device, region=region, name=i)
## if min(y) < ymin:
## ymin = min(y)
## elif max(y) > ymax:
## ymax = max(y)
## matplotlib.pyplot.plot(xmid, y)
##matplotlib.pyplot.xlabel('x (cm)')
##matplotlib.pyplot.ylabel('J (A/cm^2)')
##matplotlib.pyplot.legend(efields)
##matplotlib.pyplot.axis([min(x), max(x), 0.5*ymin, 2*ymax])
##matplotlib.pyplot.savefig("diode_1d_current.eps")
##print ymin
##print ymax