-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_DBMP.py
452 lines (305 loc) · 18.5 KB
/
test_DBMP.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
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 22 11:22:02 2023
@author: viola
"""
# import necessary modules
import functions
from functions import *
import numpy as np
from mpmath import *
from DBM_Parabolic import *
# testing of specific functions of DBM_Parabolic model
# sigma calculation
def test_sigmac_DBMP_fixed_delta():
"""
function to test the the function to calculate sigma for the conduction band
----------
Given an array of fixed input values for the energy gap (in a realistic range),
and an array of increasing input values for the chemical potential (positive and negative values in a realistic range)
when the function is applied, it gives an array containing the expected results:
- sigmac positive and increases for increasing chemical potential
----------
"""
value1 = np.asarray([1, 1, 1]) # input values for energy gap
value2 = np.asarray([-13, -2, 7]) # input values for chemical potential
expected_output = np.asarray([1.66305675e-06, 9.71747031e-02, 1.20049514e+01]) # expected results
assert np.allclose(sigmac_DBMP(value1, value2), expected_output, atol=1e-10)
def test_sigmac_DBMP_fixed_eta():
"""
function to test the the function to calculate sigma for the conduction band
----------
Given an array of increasing input values for the energy gap (positive values in a realistic range),
and an array of fixed input values for the chemical potential (in a realistic range)
when the F0c function is applied, it gives an array containing the expected results:
- sigmac positive and decreases for increasing values of energy gap
----------
"""
value1 = np.asarray([2, 7.6, 19]) # input values for energy gap
value2 = np.asarray([3, 3, 3]) # input values for chemical potential
expected_output = np.asarray([2.62652338e+00, 2.00033041e-02, 2.25070338e-07]) # expected results
assert np.allclose(sigmac_DBMP(value1, value2), expected_output, atol=1e-10)
def test_sigmav_DBMP_fixed_delta():
"""
function to test the the function to calculate sigma for the valence band
----------
Given an array of fixed input values for the energy gap (in a realistic range),
and an array of increasing input values for the chemical potential (positive and negative values in a realistic range)
when the function is applied, it gives an array containing the expected results:
- sigmav positive and decreases for increasing chemical potential
----------
"""
value1 = np.asarray([1, 1, 1]) # input values for energy gap
value2 = np.asarray([-13, -2, 7]) # input values for chemical potential
expected_output = np.asarray([2.40000123e+01, 2.62652338e+00, 6.70812746e-04]) # expected results
assert np.allclose(sigmav_DBMP(value1, value2), expected_output, atol=1e-10)
def test_sigmav_DBMP_fixed_eta():
"""
function to test the the function to calculate sigma for the valence band
----------
Given an array of increasing input values for the energy gap (positive values in a realistic range),
and an array of fixed input values for the chemical potential (in a realistic range)
when the function is applied, it gives an array containing the expected results:
- sigmav positive and decreases for increasing values of energy gap
----------
"""
value1 = np.asarray([2, 7.6, 19]) # input values for energy gap
value2 = np.asarray([3, 3, 3]) # input values for chemical potential
expected_output = np.asarray([1.34306970e-02, 4.98313987e-05, 5.57893731e-10]) # expected results
assert np.allclose(sigmav_DBMP(value1, value2), expected_output, atol=1e-10)
def test_sigma_DBMP_fixed_delta():
"""
function to test the the function to calculate sigma of the material
----------
Given an array of fixed input values for the energy gap (in a realistic range),
and an array of increasing input values for the chemical potential (positive and negative values in a realistic range)
when the function is applied, it gives an array containing the expected results:
- sigma has a quasi-parabolic behavior: decreases for increasing chemical potential when it is negative,
then increases for increasing chemical potential when it is positive
----------
"""
value1 = np.asarray([1, 1, 1]) # input values for energy gap
value2 = np.asarray([-13, -2, 7]) # input values for chemical potential
expected_output = np.asarray([24.00001395, 2.72369808, 12.00562218]) # expected results
assert np.allclose(sigma_DBMP(value1, value2), expected_output, atol=1e-10)
def test_sigma_DBMP_fixed_eta():
"""
function to test the the function to calculate sigma of the material
----------
Given an array of increasing input values for the energy gap (positive values in a realistic range),
and an array of fixed input values for the chemical potential (in a realistic range)
when the F0c function is applied, it gives an array containing the expected results:
- sigma positive and decreases for increasing values of energy gap
----------
"""
value1 = np.asarray([2, 7.6, 19]) # input values for energy gap
value2 = np.asarray([3, 3, 3]) # input values for chemical potential
expected_output = np.asarray([2.63995407e+00, 2.00531355e-02, 2.25628232e-07]) # expected results
assert np.allclose(sigma_DBMP(value1, value2), expected_output, atol=1e-10)
# S calculation
def test_Sc_DBMP_fixed_delta():
"""
function to test the the function to calculate S for the conduction band
----------
Given an array of fixed input values for the energy gap (in a realistic range),
and an array of increasing input values for the chemical potential (positive and negative values in a realistic range)
when the function is applied, it gives an array containing the expected results:
- Sc negative and increases for increasing values of chemical potential
----------
"""
value1 = np.asarray([1, 1, 1]) # input values for energy gap
value2 = np.asarray([-13, -2, 7]) # input values for chemical potential
expected_output = np.asarray([-16.000000390970271, -5.0244248243982694, -0.5447851451260235]) # expected results
assert np.allclose(Sc_DBMP(value1, value2).astype(float), expected_output, atol=1e-10)
def test_Sc_DBMP_fixed_eta():
"""
function to test the the function to calculate S for the conduction band
----------
Given an array of increasing input values for the energy gap (positive values in a realistic range),
and an array of fixed input values for the chemical potential (in a realistic range)
when the function is applied, it gives an array containing the expected results:
- Sc negative and decreases for increasing values of energy gap
----------
"""
value1 = np.asarray([2, 7.6, 19]) # input values for energy gap
value2 = np.asarray([3, 3, 3]) # input values for chemical potential
expected_output = np.asarray([-1.7508395129660097, -6.6050063834138895, -18.000000320536959]) # expected results
assert np.allclose(Sc_DBMP(value1, value2).astype(float), expected_output, atol=1e-10)
def test_Sv_DBMP_fixed_delta():
"""
function to test the the function to calculate S for the valence band
----------
Given an array of fixed input values for the energy gap (in a realistic range),
and an array of increasing input values for the chemical potential (positive and negative values in a realistic range)
when the function is applied, it gives an array containing the expected results:
- Sv positive and increases for increasing values of chemical potential
----------
"""
value1 = np.asarray([1, 1, 1]) # input values for energy gap
value2 = np.asarray([-13, -2, 7]) # input values for chemical potential
expected_output = np.asarray([0.27414836921235658, 1.7508395129660099, 10.000167709436949]) # expected results
assert np.allclose(Sv_DBMP(value1, value2).astype(float), expected_output, atol=1e-10)
def test_Sv_DBMP_fixed_eta():
"""
function to test the the function to calculate S for the valence band
----------
Given an array of increasing input values for the energy gap (positive values in a realistic range),
and an array of fixed input values for the chemical potential (in a realistic range)
when the function is applied, it gives an array containing the expected results:
- Sv positive and increases for increasing values of energy gap
----------
"""
value1 = np.asarray([2, 7.6, 19]) # input values for energy gap
value2 = np.asarray([3, 3, 3]) # input values for chemical potential
expected_output = np.asarray([7.003360179571537, 12.600012457890539, 23.999999596340341]) # expected results
assert np.allclose(Sv_DBMP(value1, value2).astype(float), expected_output, atol=1e-10)
def test_S_DBMP_fixed_delta():
"""
function to test the the function to calculate S of the material
----------
Given an array of fixed input values for the energy gap (in a realistic range),
and an array of increasing input values for the chemical potential (positive and negative values in a realistic range)
when the function is applied, it gives an array containing the expected results:
- S positive and increases for increasing chemical potential when it is negative,
decreases for increasing values in a narrow range near to zero becoming negative for positive chemical potential values,
then increases again for positive values of chemical potential
----------
"""
value1 = np.asarray([1, 1, 1, 1]) # input values for energy gap
value2 = np.asarray([-13, -2, 0.2, 7]) # input values for chemical potential
expected_output = np.asarray([0.27414724151163972, 1.5091151067248834, -0.36665404456475648, -0.54419594710939645]) # expected results
assert np.allclose(S_DBMP(value1, value2).astype(float), expected_output, atol=1e-10)
def test_S_DBMP_fixed_eta():
"""
function to test the the function to calculate S of the material
----------
Given an array of increasing input values for the energy gap (positive values in a realistic range),
and an array of fixed input values for the chemical potential (in a realistic range)
when the F0c function is applied, it gives an array containing the expected results:
- S negative and decreases for increasing values of energy gap
----------
"""
value1 = np.asarray([2, 7.6, 19]) # input values for energy gap
value2 = np.asarray([3, 3, 3]) # input values for chemical potential
expected_output = np.asarray([-1.7063027520413352, -6.5572825274719584, -17.896150122093459]) # expected results
assert np.allclose(S_DBMP(value1, value2).astype(float), expected_output, atol=1e-10)
# ke calculation
def test_kec_DBMP_fixed_delta():
"""
function to test the the function to calculate ke for the conduction band
----------
Given an array of fixed input values for the energy gap (in a realistic range),
and an array of increasing input values for the chemical potential (positive and negative values in a realistic range)
when the function is applied, it gives an array containing the expected results:
- kec positive and increases for increasing values of chemical potential
----------
"""
value1 = np.asarray([1, 1, 1]) # input values for energy gap
value2 = np.asarray([-13, -2, 7]) # input values for chemical potential
expected_output = np.asarray([3.3261141529321715e-6, 0.19552973291472187, 36.242349432268476]) # expected results
assert np.allclose(kec_DBMP(value1, value2).astype(float), expected_output, atol=1e-10)
def test_kec_DBMP_fixed_eta():
"""
function to test the the function to calculate ke for the conduction band
----------
Given an array of increasing input values for the energy gap (positive values in a realistic range),
and an array of fixed input values for the chemical potential (in a realistic range)
when the function is applied, it gives an array containing the expected results:
- kec positive and decreases for increasing values of energy gap
----------
"""
value1 = np.asarray([2, 7.6, 19]) # input values for energy gap
value2 = np.asarray([3, 3, 3]) # input values for chemical potential
expected_output = np.asarray([6.0947749765540493, 0.040056624675003705, 4.501399163888022e-7]) # expected results
assert np.allclose(kec_DBMP(value1, value2).astype(float), expected_output, atol=1e-10)
def test_kev_DBMP_fixed_delta():
"""
function to test the the function to calculate ke for the valence band
----------
Given an array of fixed input values for the energy gap (in a realistic range),
and an array of increasing input values for the chemical potential (positive and negative values in a realistic range)
when the function is applied, it gives an array containing the expected results:
- kev positive and decreases for increasing values of chemical potential
----------
"""
value1 = np.asarray([1, 1, 1]) # input values for energy gap
value2 = np.asarray([-13, -2, 7]) # input values for chemical potential
expected_output = np.asarray([77.15549150664225, 6.0947749765540475, 0.0013416817402995967]) # expected results
assert np.allclose(kev_DBMP(value1, value2).astype(float), expected_output, atol=1e-10)
def test_kev_DBMP_fixed_eta():
"""
function to test the the function to calculate ke for the valence band
----------
Given an array of increasing input values for the energy gap (positive values in a realistic range),
and an array of fixed input values for the chemical potential (in a realistic range)
when the function is applied, it gives an array containing the expected results:
- kev positive and decreases for increasing values of energy gap
----------
"""
value1 = np.asarray([2, 7.6, 19]) # input values for energy gap
value2 = np.asarray([3, 3, 3]) # input values for chemical potential
expected_output = np.asarray([0.02688394189501131, 9.9663107726927908e-5, 1.1157876875834053e-9]) # expected results
assert np.allclose(kev_DBMP(value1, value2).astype(float), expected_output, atol=1e-10)
def test_ke_DBMP_fixed_delta():
"""
function to test the the function to calculate ke of the material
----------
Given an array of fixed input values for the energy gap (in a realistic range),
and an array of increasing input values for the chemical potential (positive, null and negative values in a realistic range)
when the function is applied, it gives an array containing the expected results:
- ke is always positive and it decreases for increasing chemical potential when it is negative,
reaches a local maximum in a narrow range near zero,
then increases for positive values
----------
"""
value1 = np.asarray([1, 1, 1, 1, 1, 1, 1]) # input values for energy gap
value2 = np.asarray([-13, -2, -0.2, 0, 0.2, 5, 17]) # input values for chemical potential
expected_output = np.asarray([77.155935289843256, 10.591884828306991, 14.978132624202384, 15.132971795675514, 14.978132624202384, 23.059044241733691, 103.92296378132363]) # expected results
assert np.allclose(ke_DBMP(value1, value2).astype(float), expected_output, atol=1e-10)
def test_ke_DBMP_fixed_eta():
"""
function to test the the function to calculate ke of the material
----------
Given an array of increasinginput values for the energy gap (positive values in a realistic range),
and an array of fixed input values for the chemical potential (in a realistic range)
when the F0c function is applied, it gives an array containing the expected results:
- S positive and decreases for increasing values of energy gap
----------
"""
value1 = np.asarray([2, 7.6, 19]) # input values for energy gap
value2 = np.asarray([3, 3, 3]) # input values for chemical potential
expected_output = np.asarray([7.1456975668755973, 0.058490067175707171, 1.4329468721701097e-6]) # expected results
assert np.allclose(ke_DBMP(value1, value2).astype(float), expected_output, atol=1e-10)
# ZT calculation
def test_ZT_DBMP_fixed_delta():
"""
function to test the the function to calculate ZT of the material
----------
Given an array of fixed input values for the energy gap (in a realistic range),
and an array of increasing input values for the chemical potential (positive, null and negative values in a realistic range)
when the function is applied, it gives an array containing the expected results:
- ZT is always positive and, for increasing values of the chemical potential:
it is near to zero and increases until it reaches a local maximum,
then decreases until eta = 0 where ZT is approximately zero,
then increases again until another local maximum,
then decreases again towards zero
----------
"""
value1 = np.asarray([1, 1, 1, 1, 1, 1, 1]) # input values for energy gap
value2 = np.asarray([-13, -2, -0.2, 0, 0.2, 5, 17]) # input values for chemical potential
expected_output = np.asarray([0.023079016104636245, 0.53511809880070416, 0.010675016667360518, 2.195034301991368e-32, 0.010675016667360518, 0.20658824275862803, 0.01289424227108558]) # expected results
assert np.allclose(ZT_DBMP(value1, value2, 1).astype(float), expected_output, atol=1e-10)
def test_ZT_DBMP_fixed_eta():
"""
function to test the the function to calculate ZT of the material
----------
Given an array of increasinginput values for the energy gap (positive values in a realistic range),
and an array of fixed input values for the chemical potential (in a realistic range)
when the F0c function is applied, it gives an array containing the expected results:
- S positive and decreases for increasing values of energy gap
----------
"""
value1 = np.asarray([2, 7.6, 19]) # input values for energy gap
value2 = np.asarray([3, 3, 3]) # input values for chemical potential
expected_output = np.asarray([0.94358335728462628, 0.81459791438907991, 7.2262344238493525e-5]) # expected results
assert np.allclose(ZT_DBMP(value1, value2, 1).astype(float), expected_output, atol=1e-10)