PLaSK library
Loading...
Searching...
No Matches
shockley2d.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# This file is part of PLaSK (https://plask.app) by Photonics Group at TUL
3# Copyright (c) 2022 Lodz University of Technology
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, version 3.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13
14import unittest
15
16from numpy import *
17
18from plask import *
19from plask import material, geometry, mesh
20from electrical.shockley import Shockley2D, ShockleyCyl
21
22eps0 = 8.854187817e-6 # pF/µm
23
24@material.simple()
26 def cond(self, T):
27 return (1e+9, 1e+9)
28 def eps(self, T):
29 return 1.
30
31
33
34 def setUp(self):
35 rect = geometry.Rectangle(1000., 300., Conductor())
36 junc = geometry.Rectangle(1000., 0.02, 'GaAs')
37 junc.role = 'active'
38 stack = geometry.Stack2D()
39 stack.append(rect)
40 stack.append(junc)
41 stack.append(rect)
42 space = geometry.Cartesian2D(stack, length=1000.)
43 self.solver = Shockley2D("electrical2d")
44 self.solver.geometry = space
47 self.solver.mesh = generator
48 self.solver.beta = 10.
49 self.solver.js = 1.
50 self.solver.maxerr = 1e-5
53
55 self.solver.compute()
56 correct_current = 1e-3 * self.solver.js * (exp(self.solver.beta) - 1)
57 self.assertAlmostEqual(self.solver.get_total_current(), correct_current, 3)
58 capacitance = eps0 * material.GaAs().eps() * 1000.**2 / 0.02 # pF
59 self.assertAlmostEqual(self.solver.get_capacitance(), capacitance, 2)
60 heat = correct_current * 1.
61 self.assertAlmostEqual(self.solver.get_total_heat(), heat, 3)
62
63
65 msh = self.solver.mesh.elements.mesh
66 geo = self.solver.geometry
67 conds = [geo.get_material(point).cond(300.) if not geo.has_role('active', point) else (0.,5.) for point in msh]
68 self.assertSequenceEqual(self.solver.outConductivity(msh), conds)
69
70
71
73
74 def setUp(self):
75 cont = geometry.Rectangle(400., 100., Conductor())
76 rect = geometry.Rectangle(1000., 300., Conductor())
77 junc = geometry.Rectangle(1000., 0.02, "GaAs")
78 junc.role = 'active'
79 shelf = geometry.Shelf()
80 shelf.append(cont)
82 shelf.append(cont)
83 stack = geometry.Stack2D()
84 stack.prepend(shelf)
85 stack.prepend(rect)
86 stack.prepend(junc)
87 stack.prepend(rect)
88 space = geometry.Cylindrical(stack)
89 self.solver = ShockleyCyl("electricalcyl")
90 self.solver.geometry = space
93 self.solver.mesh = generator
94 self.solver.beta = 10.
95 self.solver.js = 1.
96 self.solver.maxerr = 1e-5
99
101 self.solver.compute(1000)
102 correct_current = 1e-3 * pi * self.solver.js * (exp(self.solver.beta) - 1)
103 self.assertAlmostEqual(self.solver.get_total_current(), correct_current, 3)
104 capacitance = eps0 * material.GaAs().eps() * pi*1000.**2 / 0.02 # pF
105 self.assertAlmostEqual(self.solver.get_capacitance(), capacitance, 2)
106 heat = correct_current * 1.
107 self.assertAlmostEqual(self.solver.get_total_heat(), heat, 3)
108
110 self.solver.beta = lambda T: log(T * 70)
111 self.solver.compute(1000)
112 correct_current = 1e-3 * pi * self.solver.js * (21000 - 1)
113 self.assertAlmostEqual(self.solver.get_total_current(), correct_current, 3)
114 self.solver.inTemperature = 250
115 self.solver.compute(1000)
116 correct_current = 1e-3 * pi * self.solver.js * (17500 - 1)
117 self.assertAlmostEqual(self.solver.get_total_current(), correct_current, 3)
118
120 msh = self.solver.mesh.elements.mesh
121 geo = self.solver.geometry
122 reference = [geo.get_material(point).cond(300.) if not geo.has_role('active', point) else (0.,5.) for point in msh]
123 ac = material.Air().cond(300.)
124 result = [ac if isnan(c[0]) else c for c in self.solver.outConductivity(msh)]
125 self.assertListEqual(result, reference)
126
127 if __name__ == '__main__':
128 def testGeometry(self):
129 fig = figure()
130 plot_geometry(self.solver.geometry, margin=0.1, color='k')
131 plot_mesh(self.solver.mesh, color='c')
132 plot_boundary(self.solver.voltage_boundary, self.solver.mesh, self.solver.geometry, cmap='bwr', s=40)
133
134
135if __name__ == '__main__':
136 test = unittest.main(exit=False)
137 show()