/
test_sesame_pdd.py
514 lines (366 loc) · 19.3 KB
/
test_sesame_pdd.py
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
import numpy as np
from pytest import approx, raises
def test_constant_doping():
# test sesame PDD process_structure when constant doping levels are passed
from solcore import material, si
from solcore.structure import Junction, Layer
from solcore.sesame_drift_diffusion.process_structure import process_structure
from solcore.state import State
Si_n = material('Si')(Nd=1e24, electron_minority_lifetime=1e-6, hole_minority_lifetime=1e-7)
Si_i = material('Si')(Na=0, Nd=0, electron_minority_lifetime=2e-6, hole_minority_lifetime=2e-7)
Si_p = material('Si')(Na=2e24, electron_minority_lifetime=1.5e-6, hole_minority_lifetime=1.5e-7)
junction = Junction([Layer(si('200nm'), Si_n),
Layer(si('2000nm'), Si_i),
Layer(si('2000nm'), Si_p)])
options = State()
options.T = 300
process_structure(junction, options)
sesame_obj = junction.sesame_sys
assert len(np.unique(sesame_obj.rho)) == 3
assert sesame_obj.rho[0] == 1e24*1e-6/sesame_obj.scaling.density
assert sesame_obj.rho[-1] == -2e24*1e-6/sesame_obj.scaling.density
def test_doping_profile():
# test process_structure when a doping profile is passed for one of the layers,
# or to the whole junction
from solcore import material, si
from solcore.structure import Junction, Layer
from solcore.sesame_drift_diffusion.process_structure import process_structure
from solcore.state import State
from scipy.interpolate import interp1d
Si_n = material('Si')(Nd=1e25, electron_minority_lifetime=1e-6, hole_minority_lifetime=1e-7)
Si_i = material('Si')(electron_minority_lifetime=2e-6, hole_minority_lifetime=2e-7)
Si_p = material('Si')(Na=2e24, electron_minority_lifetime=1.5e-6, hole_minority_lifetime=1.5e-7)
doping_profile = np.linspace(Si_n.Nd, -Si_p.Na, 2000)
x_pos = np.linspace(0, 2000, 2000) * 1e-9
doping_profile_func = interp1d(x_pos, doping_profile, fill_value=(Si_n.Nd, -Si_p.Na), bounds_error=False)
junction = Junction([Layer(si('200nm'), Si_n),
Layer(si('2000nm'), Si_i, doping_profile=doping_profile_func),
Layer(si('2000nm'), Si_p)])
options = State()
options.T = 300
process_structure(junction, options)
rho_1 = interp1d(junction.mesh, junction.sesame_sys.rho)
x_pos_2 = np.linspace(200, 2200, 2000) * 1e-9
doping_profile_func = interp1d(x_pos_2, doping_profile, fill_value=(Si_n.Nd, -Si_p.Na), bounds_error=False)
junction = Junction([Layer(si('200nm'), Si_n),
Layer(si('2000nm'), Si_i),
Layer(si('2000nm'), Si_p)], doping_profile=doping_profile_func)
process_structure(junction, options)
rho_2 = interp1d(junction.mesh, junction.sesame_sys.rho)
assert np.allclose(rho_1(junction.mesh), rho_2(junction.mesh))
def test_parameter_extraction():
# test all material parameters are correctly extracted by process_structure
from solcore.sesame_drift_diffusion.process_structure import get_material_parameters
from solcore import material
from solcore.constants import q, kb
test_mat = material('Si')(Nd=1e24, Na=2e24)
with raises(ValueError) as excinfo:
get_material_parameters(test_mat)
assert excinfo.match("nor in calculable parameters")
test_mat.hole_diffusion_length, test_mat.electron_diffusion_length = 100e-9, 200e-9
expected_tau_e = (q * test_mat.electron_diffusion_length ** 2 /
(kb * test_mat.T * test_mat.electron_mobility))
expected_tau_h = (q * test_mat.hole_diffusion_length ** 2 /
(kb * test_mat.T * test_mat.hole_mobility))
result = get_material_parameters(test_mat)
expected_dict = {
"Nc": test_mat.Nc * 1e-6,
"Nv": test_mat.Nv * 1e-6,
"Eg": test_mat.band_gap / q,
"affinity": test_mat.electron_affinity / q,
"epsilon": test_mat.relative_permittivity,
"mu_e": test_mat.electron_mobility * 1e4,
"mu_h": test_mat.hole_mobility * 1e4,
"tau_e": expected_tau_e,
"tau_h": expected_tau_h, # hole bulk lifetime (s)
"Et": 0, # energy level of bulk recombination centres (eV)
"B": test_mat.radiative_recombination * 1e6,
# radiative recombination constant (cm3/s)
"Cn": test_mat.electron_auger_recombination * 1e12,
# Auger recombination constant for electrons (cm6/s)
"Cp": test_mat.hole_auger_recombination * 1e12,
# Auger recombination constant for holes (cm6/s)
}
assert result == expected_dict
test_mat.electron_minority_lifetime = 1e-6
test_mat.hole_minority_lifetime = 1e-5
expected_dict["tau_e"] = 1e-6
expected_dict["tau_h"] = 1e-5
result = get_material_parameters(test_mat)
assert result == expected_dict
test_mat.bulk_recombination_energy = 0.5
expected_dict["Et"] = test_mat.bulk_recombination_energy / q
result = get_material_parameters(test_mat)
assert result == expected_dict
def test_compare_DA_np():
from solcore import material, si
from solcore.structure import Junction, Layer
from solcore.solar_cell_solver import solar_cell_solver, SolarCell
from solcore.analytic_solar_cells import iv_depletion
from solcore.sesame_drift_diffusion.solve_pdd import iv_sesame
from solcore.sesame_drift_diffusion.process_structure import carrier_constants
from solcore.state import State
from solcore.light_source import LightSource
GaAs_n = material('GaAs')(T=300, Nd=1e24,
hole_minority_lifetime=1e-6, electron_minority_lifetime=1e-6)
GaAs_p = material('GaAs')(T=300, Na=1e24,
hole_minority_lifetime=1e-6, electron_minority_lifetime=1e-6)
GaAs_p.electron_diffusion_length = carrier_constants("electron_diffusion_length", GaAs_p)
GaAs_n.hole_diffusion_length = carrier_constants("hole_diffusion_length", GaAs_n)
options = State()
options.wavelength = np.linspace(300, 950, 100)*1e-9
options.voltages = np.linspace(-1.3, 0.5, 30)
options.internal_voltages = np.linspace(-1.3, 0.5, 30)
options.T = 300
options.light_iv = True
options.light_source = LightSource(source_type='standard', version='AM1.5g', x=options.wavelength, output_units='photon_flux_per_m')
options.da_mode = 'green'
options.optics_method = 'TMM'
mesh = np.linspace(0, 2200, 500)*1e-9
np_junction = Junction([Layer(si('200nm'), GaAs_n, role='emitter'), Layer(si('2000nm'), GaAs_p, role='base')],
kind='DA', R_shunt=0.1, mesh=mesh, sn=10, sp=10)
solar_cell_solver(SolarCell([np_junction]), 'optics', options)
iv_depletion(np_junction, options)
depletion_current = np_junction.current
depletion_current_interp = np_junction.iv(options.voltages)
iv_sesame(np_junction, options)
sesame_current = np_junction.current
sesame_current_interp = np_junction.iv(options.voltages)
assert depletion_current[-1] == approx(sesame_current[-1], rel=0.05)
assert np.sign(depletion_current[0]) == np.sign(sesame_current[0])
assert depletion_current_interp[-1] == approx(sesame_current_interp[-1], rel=0.05)
assert np.sign(depletion_current_interp[0]) == np.sign(sesame_current_interp[0])
assert np.all(sesame_current == sesame_current_interp)
def test_compare_DA_pn():
from solcore import material, si
from solcore.structure import Junction, Layer
from solcore.solar_cell_solver import solar_cell_solver, SolarCell
from solcore.analytic_solar_cells import iv_depletion
from solcore.sesame_drift_diffusion.solve_pdd import iv_sesame
from solcore.sesame_drift_diffusion.process_structure import carrier_constants
from solcore.state import State
from solcore.light_source import LightSource
GaAs_p = material('GaAs')(T=300, Na=1e24,
hole_minority_lifetime=1e-6, electron_minority_lifetime=1e-6)
GaAs_n = material('GaAs')(T=300, Nd=1e24,
hole_minority_lifetime=1e-6, electron_minority_lifetime=1e-6)
GaAs_p.electron_diffusion_length = carrier_constants("electron_diffusion_length", GaAs_p)
GaAs_n.hole_diffusion_length = carrier_constants("hole_diffusion_length", GaAs_n)
options = State()
options.wavelength = np.linspace(300, 950, 100)*1e-9
options.voltages = np.linspace(-0.5, 1.3, 30)
options.internal_voltages = np.linspace(-0.5, 1.3, 30)
options.T = 300
options.light_iv = True
options.light_source = LightSource(source_type='standard', version='AM1.5g', x=options.wavelength, output_units='photon_flux_per_m')
options.da_mode = 'green'
options.optics_method = 'TMM'
mesh = np.linspace(0, 2200, 500)*1e-9
pn_junction = Junction([Layer(si('200nm'), GaAs_p, role='emitter'), Layer(si('2000nm'), GaAs_n, role='base')],
kind='DA', R_shunt=0.1, mesh=mesh)
solar_cell_solver(SolarCell([pn_junction]), 'optics', options)
iv_depletion(pn_junction, options)
depletion_current = pn_junction.current
depletion_current_interp = pn_junction.iv(options.voltages)
iv_sesame(pn_junction, options)
sesame_current = pn_junction.current
sesame_current_interp = pn_junction.iv(options.voltages)
assert depletion_current[0] == approx(sesame_current[0], rel=0.05)
assert np.sign(depletion_current[-1]) == np.sign(sesame_current[-1])
assert depletion_current_interp[0] == approx(sesame_current_interp[0], rel=0.05)
assert np.sign(depletion_current_interp[-1]) == np.sign(sesame_current_interp[-1])
assert np.all(sesame_current == sesame_current_interp)
def test_qe():
from solcore import material, si
from solcore.structure import Junction, Layer
from solcore.solar_cell_solver import solar_cell_solver, SolarCell
from solcore.analytic_solar_cells import qe_depletion
from solcore.sesame_drift_diffusion.solve_pdd import qe_sesame
from solcore.sesame_drift_diffusion.process_structure import carrier_constants
from solcore.state import State
GaAs_p = material('GaAs')(T=300, Na=1e24,
hole_minority_lifetime=1e-6,
electron_minority_lifetime=1e-6)
GaAs_n = material('GaAs')(T=300, Nd=1e24,
hole_minority_lifetime=1e-6,
electron_minority_lifetime=1e-6)
GaAs_p.electron_diffusion_length = carrier_constants("electron_diffusion_length", GaAs_p)
GaAs_n.hole_diffusion_length = carrier_constants("hole_diffusion_length", GaAs_n)
wls = np.linspace(300, 950, 100)*1e-9
options = State()
options.wavelength = wls
options.T = 300
options.light_iv = True
options.da_mode = 'green'
options.optics_method = 'BL'
mesh = np.linspace(0, 2500, 1000) * 1e-9
pn_junction = Junction([Layer(si('500nm'), GaAs_p, role='emitter'),
Layer(si('2000nm'), GaAs_n, role='base')],
kind='DA', R_shunt=0.1, mesh=mesh,
sn=1e5, sp=1e5)
solar_cell_solver(SolarCell([pn_junction]), 'optics', options)
qe_sesame(pn_junction, options)
sesame_EQE = pn_junction.eqe(wls)
sesame_IQE = pn_junction.iqe(wls)
qe_depletion(pn_junction, options)
depletion_EQE = pn_junction.eqe(wls)
depletion_IQE = pn_junction.iqe(wls)
assert sesame_EQE == approx(depletion_EQE, rel=0.1)
assert sesame_IQE == approx(depletion_IQE, rel=0.1)
def test_mesh_generation():
from solcore.sesame_drift_diffusion.process_structure import make_mesh
from solcore import material, si
from solcore.structure import Junction, Layer
from solcore.state import State
GaAs_n = material('GaAs')()
GaAs_p = material('GaAs')()
options = State(minimum_spacing=1e-9, maximum_spacing=1e-9)
pn_junction = Junction([Layer(si('500nm'), GaAs_n),
Layer(si('2000nm'), GaAs_p)])
layer_width = [layer.width*1e2 for layer in pn_junction]
make_mesh(pn_junction, layer_width, options, [500e-7])
assert pn_junction.mesh == approx(np.arange(0, 2500.01, 1)*1e-9)
def test_get_srv_np(np_junction):
from solcore.sesame_drift_diffusion.process_structure import get_srv, process_structure
from solcore import material, si
from solcore.structure import Junction, Layer
from solcore.state import State
options = State(T=300)
GaAs_n = material('GaAs')(T=300, Nd=1e24,
hole_minority_lifetime=1e-6, electron_minority_lifetime=1e-6)
GaAs_p = material('GaAs')(T=300, Na=1e24,
hole_minority_lifetime=1e-6, electron_minority_lifetime=1e-6)
junction = Junction([Layer(si('200nm'), GaAs_n, role='emitter'), Layer(si('2000nm'), GaAs_p, role='base')])
junction.sn = 5
junction.sp = 8
process_structure(junction, options)
Sfront_e, Sfront_h, Sback_e, Sback_h = get_srv(junction)
assert Sfront_e == junction.sn*100
assert Sfront_h == junction.sn*100
assert Sback_e == junction.sp*100
assert Sback_e == junction.sp*100
junction.sn_e = 2
junction.sn_h = 3
junction.sp_e = 4
junction.sp_h = 5
Sfront_e, Sfront_h, Sback_e, Sback_h = get_srv(junction)
assert Sfront_e == junction.sn_e*100
assert Sfront_h == junction.sn_h*100
assert Sback_e == junction.sp_e*100
assert Sback_h == junction.sp_h*100
def test_get_srv_pn(np_junction):
from solcore.sesame_drift_diffusion.process_structure import get_srv, process_structure
from solcore import material, si
from solcore.structure import Junction, Layer
from solcore.state import State
options = State(T=300)
GaAs_p = material('GaAs')(T=300, Na=1e24,
hole_minority_lifetime=1e-6, electron_minority_lifetime=1e-6)
GaAs_n = material('GaAs')(T=300, Nd=1e24,
hole_minority_lifetime=1e-6, electron_minority_lifetime=1e-6)
junction = Junction([Layer(si('200nm'), GaAs_p, role='emitter'), Layer(si('2000nm'), GaAs_n, role='base')])
junction.sn = 5
junction.sp = 8
process_structure(junction, options)
Sfront_e, Sfront_h, Sback_e, Sback_h = get_srv(junction)
assert Sfront_e == junction.sp*100
assert Sfront_h == junction.sp*100
assert Sback_e == junction.sn*100
assert Sback_e == junction.sn*100
junction.sn_e = 2
junction.sn_h = 3
junction.sp_e = 4
junction.sp_h = 5
Sfront_e, Sfront_h, Sback_e, Sback_h = get_srv(junction)
assert Sfront_e == junction.sp_e*100
assert Sfront_h == junction.sp_h*100
assert Sback_e == junction.sn_e*100
assert Sback_h == junction.sn_h*100
def test_voltages_np():
from solcore import material, si
from solcore.structure import Junction, Layer
from solcore.solar_cell_solver import solar_cell_solver, SolarCell
from solcore.sesame_drift_diffusion import iv_sesame
from solcore.state import State
from solcore.light_source import LightSource
GaAs_n = material('GaAs')(T=300, Nd=1e24,
hole_minority_lifetime=1e-6, electron_minority_lifetime=1e-6)
GaAs_p = material('GaAs')(T=300, Na=1e24,
hole_minority_lifetime=1e-6, electron_minority_lifetime=1e-6)
options = State()
options.wavelength = np.linspace(300, 950, 100)*1e-9
options.T = 300
options.light_iv = True
options.light_source = LightSource(source_type='standard', version='AM1.5g', x=options.wavelength, output_units='photon_flux_per_m')
options.optics_method = 'TMM'
np_junction = Junction([Layer(si('200nm'), GaAs_n, role='emitter'), Layer(si('2000nm'), GaAs_p, role='base')],
kind='sesame_PDD')
solar_cell_solver(SolarCell([np_junction]), 'optics', options)
voltage_end = [0, 1.3, 1.3]
voltage_points = [20, 41, 40]
interp_voltages = np.linspace(-1, 0, 10)
interp_results = np.zeros((len(voltage_end), len(interp_voltages)))
for i, V_end in enumerate(voltage_end):
options.voltages = np.linspace(-1.3, V_end, voltage_points[i])
options.internal_voltages = np.linspace(-1.3, V_end, voltage_points[i])
iv_sesame(np_junction, options)
interp_results[i] = np_junction.iv(interp_voltages)
assert interp_results[0] == approx(interp_results[1], rel=0.02)
assert interp_results[1] == approx(interp_results[2], rel=0.02)
def test_voltages_pn():
from solcore import material, si
from solcore.structure import Junction, Layer
from solcore.solar_cell_solver import solar_cell_solver, SolarCell
from solcore.sesame_drift_diffusion import iv_sesame
from solcore.state import State
from solcore.light_source import LightSource
GaAs_p = material('GaAs')(T=300, Na=1e24,
hole_minority_lifetime=1e-6, electron_minority_lifetime=1e-6)
GaAs_n = material('GaAs')(T=300, Nd=1e24,
hole_minority_lifetime=1e-6, electron_minority_lifetime=1e-6)
options = State()
options.wavelength = np.linspace(300, 950, 100)*1e-9
options.T = 300
options.light_iv = True
options.light_source = LightSource(source_type='standard', version='AM1.5g', x=options.wavelength, output_units='photon_flux_per_m')
options.optics_method = 'TMM'
pn_junction = Junction([Layer(si('200nm'), GaAs_p, role='emitter'), Layer(si('2000nm'), GaAs_n, role='base')],
kind='sesame_PDD')
solar_cell_solver(SolarCell([pn_junction]), 'optics', options)
voltage_start = [0, -1.3, -1.3]
voltage_points = [20, 41, 40]
interp_voltages = np.linspace(0, 1, 10)
interp_results = np.zeros((len(voltage_start), len(interp_voltages)))
for i, V_start in enumerate(voltage_start):
options.voltages = np.linspace(V_start, 1.3, voltage_points[i])
options.internal_voltages = np.linspace(V_start, 1.3, voltage_points[i])
iv_sesame(pn_junction, options)
interp_results[i] = pn_junction.iv(interp_voltages)
assert interp_results[0] == approx(interp_results[1], rel=0.02)
assert interp_results[1] == approx(interp_results[2], rel=0.02)
def test_reverse_bias():
from solcore import material, si
from solcore.structure import Junction, Layer
from solcore.solar_cell_solver import solar_cell_solver, SolarCell
from solcore.sesame_drift_diffusion import iv_sesame
from solcore.state import State
from solcore.light_source import LightSource
GaAs_n = material('GaAs')(T=300, Nd=1e24,
hole_minority_lifetime=1e-6, electron_minority_lifetime=1e-6)
GaAs_p = material('GaAs')(T=300, Na=1e24,
hole_minority_lifetime=1e-6, electron_minority_lifetime=1e-6)
options = State()
options.wavelength = np.linspace(300, 950, 100)*1e-9
options.T = 300
options.light_iv = True
options.light_source = LightSource(source_type='standard', version='AM1.5g', x=options.wavelength, output_units='photon_flux_per_m')
options.optics_method = 'TMM'
np_junction = Junction([Layer(si('200nm'), GaAs_n, role='emitter'), Layer(si('2000nm'), GaAs_p, role='base')],
kind='sesame_PDD')
solar_cell_solver(SolarCell([np_junction]), 'optics', options)
options.voltages = np.linspace(0, 1.3, 10)
options.internal_voltages = options.voltages
iv_sesame(np_junction, options)
# this is reverse bias for an n-p junction, so check that all currents are > 0:
assert np.all(np_junction.current > 0)
assert np.all(np_junction.iv(options.voltages) > 0)