forked from aestimosolver/aestimo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaestimo_h.py
executable file
·1349 lines (1258 loc) · 62.8 KB
/
aestimo_h.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
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""This is the 3x3 k.p aestimo calculator for valence band calculations
(Numpy version, there is no classic version for valence band calculations).
It can be used similarly to the aestimo.py module. aestimo_h.py can be used as
a script or a libary.
To use as a script, define the simulation in a python file. See the following
sample files for examples on usage and the required parameters:
sample-qw-barrierdope-p.py
sample-qw-barrierdope-p_cdzno.py
sample-qw-barrierdope-p_ingran.py
sample-multi-qw-barrierdope-p.py
sample-multi-qw-barrierdope-p_ingran.py
and then run aestimo on the command line as
./aestimo.py -i <input file>
Since we are abusing the python module system, the input 'file' needs to be
importable by the aestimo script. Alternatively, define the input file in the
config module using the inputfilename parameter.
To use aestimo_h.py as a library, first create an instance of the StructureFrom
class which builds the arrays describing a structure from the same input
parameters that are found in the sample files. A simple list format is used to
describes the structure's layers.
"""
"""
Aestimo 1D Schrodinger-Poisson Solver
Copyright (C) 2013-2016 Sefer Bora Lisesivdin and Aestimo group
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. See ~/COPYING file or http://www.gnu.org/copyleft/gpl.txt .
For the list of contributors, see ~/AUTHORS
"""
__version__='1.1.0'
import time
time0 = time.time() # timing audit
#from scipy.optimize import fsolve
import matplotlib.pyplot as pl
import numpy as np
alen = np.alen
import os
from math import log,exp,sqrt
import VBHM
from scipy import linalg
from VBHM import qsv,VBMAT1,VBMAT2,VBMAT_V,CBMAT,CBMAT_V
import config,database
# --------------------------------------
import logging
logger = logging.getLogger('aestimo_h')
hdlr = logging.FileHandler(config.logfile)
formatter = logging.Formatter('%(asctime)s %(levelname)s %(name)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
#stderr
ch = logging.StreamHandler()
formatter2 = logging.Formatter('%(levelname)s %(message)s')
ch.setFormatter(formatter2)
logger.addHandler(ch)
# LOG level can be INFO, WARNING, ERROR
logger.setLevel(logging.INFO)
os.sys.stderr.write("WARNING aestimo_h logs automatically to aestimo.log in the current working directory.\n")
# --------------------------------------
#Defining constants and material parameters
q = 1.602176e-19 #C
kb = 1.3806504e-23 #J/K
nii = 0.0
hbar = 1.054588757e-34
m_e= 9.1093826E-31 #kg
pi=np.pi
eps0= 8.8541878176e-12 #F/m
J2meV=1e3/q #Joules to meV
meV2J=1e-3*q #meV to Joules
time1 = time.time() # timing audit
#logger.info("Aestimo is starting...")
# Input Class
# -------------------------------------
def round2int(x):
"""int is sensitive to floating point numerical errors near whole numbers,
this moves the discontinuity to the half interval. It is also equivalent
to the normal rules for rounding positive numbers."""
# int(x + (x>0) -0.5) # round2int for positive and negative numbers
return int(x+0.5)
class Structure():
def __init__(self,database,**kwargs):
"""This class holds details on the structure to be simulated.
database is the module containing the material properties. Then
this class should have the following attributes set
Fapp - applied field (Vm**-1)
T - Temperature (K)
subnumber_e - number of subbands to look for.
comp_scheme - computing scheme
dx - grid step size (m)
n_max - number of grid points
cb_meff #conduction band effective mass (kg) (array, len n_max)
cb_meff_alpha #non-parabolicity constant.
fi #Bandstructure potential (J) (array, len n_max)
eps #dielectric constant (including eps0) (array, len n_max)
dop #doping distribution (m**-3) (array, len n_max)
These last 4 can be created by using the method
create_structure_arrays(material_list)
"""
# setting any parameters provided with initialisation
for key,value in kwargs.items():
setattr(self,key,value)
# Loading materials database
self.material_property = database.materialproperty
totalmaterial = alen(self.material_property)
self.alloy_property = database.alloyproperty
totalalloy = alen(self.alloy_property)
logger.info("Total material number in database: %d" ,(totalmaterial + totalalloy))
def create_structure_arrays(self):
""" initialise arrays/lists for structure"""
self.N_wells_real0=sum(sum(np.char.count(self.material, 'w')))
# Calculate the required number of grid points
self.x_max = sum([layer[0] for layer in self.material])*1e-9 #total thickness (m)
n_max = round2int(self.x_max/self.dx)
# Check on n_max
maxgridpoints = self.maxgridpoints
mat_type= self.mat_type
if n_max > maxgridpoints:
logger.error("Grid number is exceeding the max number of %d",maxgridpoints)
exit()
#
self.n_max = n_max
dx =self.dx
material_property = self.material_property
alloy_property = self.alloy_property
cb_meff = np.zeros(n_max) #conduction band effective mass
cb_meff_alpha = np.zeros(n_max) #non-parabolicity constant.
m_hh = np.zeros(n_max)
m_lh = np.zeros(n_max)
m_so = np.zeros(n_max)
# Elastic constants C11,C12
C12 = np.zeros(n_max)
C11 = np.zeros(n_max)
#Elastic constants Wurtzite C13,C33
C13 = np.zeros(n_max)
C33 = np.zeros(n_max)
C44 = np.zeros(n_max)
#Spontaneous and Piezoelectric Polarizations constants D15,D13,D33 and Psp
D15 = np.zeros(n_max)
D31 = np.zeros(n_max)
D33 = np.zeros(n_max)
Psp = np.zeros(n_max)
# Luttinger Parameters γ1,γ2,γ3
GA3 = np.zeros(n_max)
GA2 = np.zeros(n_max)
GA1 = np.zeros(n_max)
#Hole eff. mass parameter Wurtzite Semiconductors
A1 = np.zeros(n_max)
A2 = np.zeros(n_max)
A3 = np.zeros(n_max)
A4= np.zeros(n_max)
A5 = np.zeros(n_max)
A6 = np.zeros(n_max)
# Lattice constant a0
a0 = np.zeros(n_max)
a0_wz = np.zeros(n_max)
a0_sub =np.zeros(n_max)
# Deformation potentials ac,av,b
Ac = np.zeros(n_max)
Av = np.zeros(n_max)
B = np.zeros(n_max)
# Deformation potentials Wurtzite Semiconductors
D1 = np.zeros(n_max)
D2 = np.zeros(n_max)
D3 = np.zeros(n_max)
D4 = np.zeros(n_max)
delta = np.zeros(n_max) #delta splitt off
delta_so = np.zeros(n_max) #delta Spin–orbit split energy
delta_cr = np.zeros(n_max) #delta Crystal-field split energy
# Strain related
fi_h = np.zeros(n_max) #Bandstructure potential
fi = np.zeros(n_max) #Bandstructure potential
eps =np.zeros(n_max) #dielectric constant
dop = np.zeros(n_max) #doping
N_wells_real=0
N_wells_real2=0
N_wells_real0=self.N_wells_real0
N_wells_virtual=N_wells_real0+2
N_wells_virtual2=N_wells_real0+2
Well_boundary=np.zeros((N_wells_virtual,2),dtype=int)
Well_boundary2=np.zeros((N_wells_virtual,2),dtype=int)
barrier_boundary=np.zeros((N_wells_virtual+1,2),dtype=int)
n_max_general=np.zeros(N_wells_virtual,dtype=int)
Well_boundary[N_wells_virtual-1,0]=n_max
Well_boundary[N_wells_virtual-1,1]=n_max
Well_boundary2[N_wells_virtual-1,0]=n_max
Well_boundary2[N_wells_virtual-1,1]=n_max
barrier_boundary[N_wells_virtual,0]=n_max
barrier_len=np.zeros(N_wells_virtual+1)
position = 0.0 # keeping in nanometres (to minimise errors)
for layer in self.material:
startindex = round2int(position*1e-9/dx)
position += layer[0] # update position to end of the layer
finishindex = round2int(position*1e-9/dx)
#
matType = layer[1]
if matType in material_property:
matprops = material_property[matType]
cb_meff[startindex:finishindex] = matprops['m_e']*m_e
cb_meff_alpha[startindex:finishindex] = matprops['m_e_alpha']
fi[startindex:finishindex] = matprops['Band_offset']*matprops['Eg']*q #Joule
if mat_type=='Zincblende' :
a0_sub[startindex:finishindex]=matprops['a0']*1e-10
C11[startindex:finishindex] = matprops['C11']
C12[startindex:finishindex] = matprops['C12']
GA1[startindex:finishindex] = matprops['GA1']
GA2[startindex:finishindex] = matprops['GA2']
GA3[startindex:finishindex] = matprops['GA3']
Ac[startindex:finishindex] = matprops['Ac']*q
Av[startindex:finishindex] = matprops['Av']*q
B[startindex:finishindex] = matprops['B']*q
delta[startindex:finishindex] = matprops['delta']*q
fi_h[startindex:finishindex] =-(1-matprops['Band_offset'])*matprops['Eg']*q #Joule #-0.8*q-(1-matprops['Band_offset'])*matprops['Eg']*q #Joule
eps[startindex:finishindex] = matprops['epsilonStatic']*eps0
a0[startindex:finishindex] = matprops['a0']*1e-10
if mat_type=='Wurtzite' :
a0_sub[startindex:finishindex]=matprops['a0_wz']*1e-10
C11[startindex:finishindex] = matprops['C11']*1e10
C12[startindex:finishindex] = matprops['C12']*1e10
C13[startindex:finishindex] = matprops['C13']*1e10
C33[startindex:finishindex] = matprops['C33']*1e10
A1[startindex:finishindex] = matprops['A1']
A2[startindex:finishindex] = matprops['A2']
A3[startindex:finishindex] = matprops['A3']
A4[startindex:finishindex] = matprops['A4']
A5[startindex:finishindex] = matprops['A5']
A6[startindex:finishindex] = matprops['A6']
Ac[startindex:finishindex] = matprops['Ac']*q
D1[startindex:finishindex] = matprops['D1']*q
D2[startindex:finishindex] = matprops['D2']*q
D3[startindex:finishindex] = matprops['D3']*q
D4[startindex:finishindex] = matprops['D4']*q
a0_wz[startindex:finishindex] = matprops['a0_wz']*1e-10
delta_so[startindex:finishindex] = matprops['delta_so']*q
delta_cr[startindex:finishindex] = matprops['delta_cr']*q
eps[startindex:finishindex] = matprops['epsilonStatic']*eps0
fi_h[startindex:finishindex] =-(1-matprops['Band_offset'])*matprops['Eg']*q
Psp[startindex:finishindex]=matprops['Psp']
elif matType in alloy_property:
alloyprops = alloy_property[matType]
mat1 = material_property[alloyprops['Material1']]
mat2 = material_property[alloyprops['Material2']]
x = layer[2] #alloy ratio
cb_meff_alloy = x*mat1['m_e'] + (1-x)* mat2['m_e']
cb_meff[startindex:finishindex] = cb_meff_alloy*m_e
Eg = x*mat1['Eg'] + (1-x)* mat2['Eg']-alloyprops['Bowing_param']*x*(1-x) #eV
fi[startindex:finishindex] = alloyprops['Band_offset']*Eg*q # for electron. Joule
a0_sub[startindex:finishindex]=alloyprops['a0_sub']*1e-10
if mat_type=='Zincblende':
C11[startindex:finishindex] = x*mat1['C11'] + (1-x)* mat2['C11']
C12[startindex:finishindex] = x*mat1['C12'] + (1-x)* mat2['C12']
GA1[startindex:finishindex] =x*mat1['GA1'] + (1-x)* mat2['GA1']
GA2[startindex:finishindex] = x*mat1['GA2'] + (1-x)* mat2['GA2']
GA3[startindex:finishindex] = x*mat1['GA3'] + (1-x)* mat2['GA3']
Ac_alloy = x*mat1['Ac'] + (1-x)* mat2['Ac']
Ac[startindex:finishindex] = Ac_alloy*q
Av_alloy = x*mat1['Av'] + (1-x)* mat2['Av']
Av[startindex:finishindex] = Av_alloy*q
B_alloy = x*mat1['B'] + (1-x)* mat2['B']
B[startindex:finishindex] = B_alloy*q
delta_alloy = x*mat1['delta'] + (1-x)* mat2['delta']
delta[startindex:finishindex] = delta_alloy*q
fi_h[startindex:finishindex] = -(1-alloyprops['Band_offset'])*Eg*q # -(-1.33*(1-x)-0.8*x)for electron. Joule-1.97793434e-20 #
eps[startindex:finishindex] = (x*mat1['epsilonStatic'] + (1-x)* mat2['epsilonStatic'] )*eps0
a0[startindex:finishindex] = ((1-x)*mat1['a0'] + x* mat2['a0'] )*1e-10
cb_meff_alpha[startindex:finishindex] = alloyprops['m_e_alpha']*(mat2['m_e']/cb_meff_alloy) #non-parabolicity constant for alloy. THIS CALCULATION IS MOSTLY WRONG. MUST BE CONTROLLED. SBL
if mat_type=='Wurtzite' :
A1[startindex:finishindex] =x*material_property[alloyprops['Material1']]['A1'] + (1-x)* material_property[alloyprops['Material2']]['A1']
A2[startindex:finishindex] =x*material_property[alloyprops['Material1']]['A2'] + (1-x)* material_property[alloyprops['Material2']]['A2']
A3[startindex:finishindex] =x*material_property[alloyprops['Material1']]['A3'] + (1-x)* material_property[alloyprops['Material2']]['A3']
A4[startindex:finishindex] =x*material_property[alloyprops['Material1']]['A4'] + (1-x)* material_property[alloyprops['Material2']]['A4']
A5[startindex:finishindex] =x*material_property[alloyprops['Material1']]['A5'] + (1-x)* material_property[alloyprops['Material2']]['A5']
A6[startindex:finishindex] =x*material_property[alloyprops['Material1']]['A6'] + (1-x)* material_property[alloyprops['Material2']]['A6']
D1[startindex:finishindex] =(x*material_property[alloyprops['Material1']]['D1'] + (1-x)* material_property[alloyprops['Material2']]['D1'])*q
D2[startindex:finishindex] =(x*material_property[alloyprops['Material1']]['D2'] + (1-x)* material_property[alloyprops['Material2']]['D2'])*q
D3[startindex:finishindex] =(x*material_property[alloyprops['Material1']]['D3'] + (1-x)* material_property[alloyprops['Material2']]['D3'])*q
D4[startindex:finishindex] =(x*material_property[alloyprops['Material1']]['D4'] + (1-x)* material_property[alloyprops['Material2']]['D4'])*q
C13[startindex:finishindex] = (x*material_property[alloyprops['Material1']]['C13'] + (1-x)* material_property[alloyprops['Material2']]['C13'])*1e10# for newton/meter²
C33[startindex:finishindex] = (x*material_property[alloyprops['Material1']]['C33'] + (1-x)* material_property[alloyprops['Material2']]['C33'])*1e10
D31[startindex:finishindex] = x*material_property[alloyprops['Material1']]['D31'] + (1-x)* material_property[alloyprops['Material2']]['D31']
D33[startindex:finishindex] = x*material_property[alloyprops['Material1']]['D33'] + (1-x)* material_property[alloyprops['Material2']]['D33']
Psp[startindex:finishindex] = x*material_property[alloyprops['Material1']]['Psp'] + (1-x)* material_property[alloyprops['Material2']]['Psp']
C11[startindex:finishindex] = (x*material_property[alloyprops['Material1']]['C11'] + (1-x)* material_property[alloyprops['Material2']]['C11'])*1e10
C12[startindex:finishindex] = (x*material_property[alloyprops['Material1']]['C12'] + (1-x)* material_property[alloyprops['Material2']]['C12'])*1e10
a0_wz[startindex:finishindex] = ( x*material_property[alloyprops['Material1']]['a0_wz'] +(1-x)* material_property[alloyprops['Material2']]['a0_wz'])*1e-10
eps[startindex:finishindex] = (x*material_property[alloyprops['Material1']]['epsilonStatic'] + (1-x)* material_property[alloyprops['Material2']]['epsilonStatic'])*eps0
fi_h[startindex:finishindex] =-(1-alloyprops['Band_offset'])*Eg*q
delta_so[startindex:finishindex] = (x*material_property[alloyprops['Material1']]['delta_so'] + (1-x)* material_property[alloyprops['Material2']]['delta_so'])*q
delta_cr[startindex:finishindex] = (x*material_property[alloyprops['Material1']]['delta_cr'] + (1-x)* material_property[alloyprops['Material2']]['delta_cr'])*q
Ac_alloy = x*material_property[alloyprops['Material1']]['Ac'] + (1-x)* material_property[alloyprops['Material2']]['Ac']
Ac[startindex:finishindex] = Ac_alloy*q
matRole= layer[5]
if matRole == 'w':
N_wells_real2+=1
Well_boundary2[N_wells_real2,0]=startindex
Well_boundary2[N_wells_real2,1]=finishindex
for J in range(0,N_wells_virtual2):
barrier_boundary[J,0]=Well_boundary2[J-1,1]
barrier_boundary[J,1]=Well_boundary2[J,0]
barrier_len[J]=barrier_boundary[J,1]-barrier_boundary[J,0]
#doping
if layer[4] == 'n':
chargedensity = layer[3]*1e6 #charge density in m**-3 (conversion from cm**-3)
elif layer[4] == 'p':
chargedensity = -layer[3]*1e6 #charge density in m**-3 (conversion from cm**-3)
else:
chargedensity = 0.0
dop[startindex:finishindex] = chargedensity
#here we remove barriers who are less than anti_crossing_length
#so we can constructe the new well boundary using the resulted barrier boundary
brr=0
anti_crossing_length=config.anti_crossing_length*1e-9
for J in range(2,N_wells_virtual2-1):
if (barrier_len[J]*dx <= anti_crossing_length ) :
brr+=1
brr_vec=np.zeros(brr)
brr2=0
for J in range(2,N_wells_virtual2-1):
if (barrier_len[J]*dx <= anti_crossing_length ) :
brr2+=1
brr_vec[brr2-1]=J+1-brr2
for I in range (0,brr):
barrier_boundary=np.delete(barrier_boundary,brr_vec[I], 0)
N_wells_virtual=N_wells_virtual-brr
Well_boundary=np.resize(Well_boundary,(N_wells_virtual,2))
for J in range(0,N_wells_virtual):
Well_boundary[J-1,1]=barrier_boundary[J,0]
Well_boundary[J,0]=barrier_boundary[J,1]
self.fi = fi
self.cb_meff = cb_meff
self.cb_meff_alpha = cb_meff_alpha
self.dop = dop
#return fi,cb_meff,eps,dop
self.C11 = C11
self.C12 = C12
self.GA1 = GA1
self.GA2 = GA2
self.GA3 = GA3
self.Ac = Ac
self.Av = Av
self.B = B
self.a0 = a0
self.delta = delta
self.fi_h = fi_h
self.eps = eps
self.A1 = A1
self.A2 = A2
self.A3 = A3
self.A4 = A4
self.A5 = A5
self.A6 = A6
self.D1 = D1
self.D2 = D2
self.D3 = D3
self.D4 = D4
self.C13 = C13
self.C33 = C33
self.D31 = D31
self.D33 = D33
self.Psp = Psp
self.a0_wz = a0_wz
self.a0_sub = a0_sub
self.delta_so = delta_so
self.delta_cr = delta_cr
self.N_wells_virtual=N_wells_virtual
self.N_wells_virtual2=N_wells_virtual2
self.N_wells_real0=N_wells_real0
self.Well_boundary=Well_boundary
self.Well_boundary2=Well_boundary2
self.barrier_boundary=barrier_boundary
class AttrDict(dict):
"""turns a dictionary into an object with attribute style lookups"""
def __init__(self, *args, **kwargs):
super(AttrDict, self).__init__(*args, **kwargs)
self.__dict__ = self
class StructureFrom(Structure):
def __init__(self,inputfile,database):
if type(inputfile)==dict:
inputfile=AttrDict(inputfile)
# Parameters for simulation
self.Fapp = inputfile.Fapplied
self.T = inputfile.T
self.subnumber_h = inputfile.subnumber_h
self.subnumber_e = inputfile.subnumber_e
self.comp_scheme = inputfile.computation_scheme
self.dx = inputfile.gridfactor*1e-9 #grid in m
self.maxgridpoints = inputfile.maxgridpoints
self.mat_type = inputfile.mat_type
# Loading material list
self.material = inputfile.material
totallayer = alen(self.material)
logger.info("Total layer number: %s",totallayer)
# Calculate the required number of grid points
self.x_max = sum([layer[0] for layer in self.material])*1e-9 #total thickness (m)
self.n_max = int(self.x_max/self.dx)
# Check on n_max
max_val = inputfile.maxgridpoints
if self.n_max > max_val:
logger.error(" Grid number is exceeding the max number of %d", max_val)
exit()
# Loading materials database #
self.material_property = database.materialproperty
totalmaterial = alen(self.material_property)
self.alloy_property = database.alloyproperty
totalalloy = alen(self.alloy_property)
logger.info("Total number of materials in database: %d" %(totalmaterial+totalalloy))
# Initialise arrays
#cb_meff #conduction band effective mass (array, len n_max)
#fi #Bandstructure potential (array, len n_max)
#eps #dielectric constant (array, len n_max)
#dop #doping distribution (array, len n_max)
self.create_structure_arrays()
# No Shooting method parameters for Schrödinger Equation solution since we use a 3x3 KP solver
#delta_E = 1.0*meV2J #Energy step (Joules) for initial search. Initial delta_E is 1 meV. #This can be included in config as a setting?
#d_E = 1e-5*meV2J #Energy step (Joules) for Newton-Raphson method when improving the precision of the energy of a found level.
damping = 0.4 #averaging factor between iterations to smooth convergence.
max_iterations=80 #maximum number of iterations.
convergence_test=1e-6 #convergence is reached when the ground state energy (meV) is stable to within this number between iterations.
# DO NOT EDIT UNDER HERE FOR PARAMETERS
# --------------------------------------
#Vegard's law for alloys
def vegard(first,second,mole):
return first*mole+second*(1-mole)
# FUNCTIONS for FERMI-DIRAC STATISTICS-----------------------------------------
def fd1(Ei,Ef,model):#use
"""integral of Fermi Dirac Equation for energy independent density of states.
Ei [meV], Ef [meV], T [K]"""
T= model.T
return kb*T*log(exp(meV2J*(Ei-Ef)/(kb*T))+1)
def fd2(Ei,Ef,model):
"""integral of Fermi Dirac Equation for energy independent density of states.
Ei [meV], Ef [meV], T [K]"""
T= model.T
return kb*T*log(exp(meV2J*(Ef-Ei)/(kb*T))+1)
def calc_meff_state_general(wfh,wfe,model,fi,E_statec,list,m_hh,m_lh,m_so,n_max_general,j,Well_boundary):
vb_meff= np.zeros((model.subnumber_h,n_max_general))
#
for i in range(0,model.subnumber_h,1):
if list[i]=='hh1' or list[i]=='hh2' or list[i]=='hh3':
vb_meff[i]=m_hh[Well_boundary[j-1,1]:Well_boundary[j+1,0]]
elif list[i] =='lh1'or list[i] =='lh2'or list[i] =='lh3':
vb_meff[i]=m_lh[Well_boundary[j-1,1]:Well_boundary[j+1,0]]
else:
vb_meff[i]=m_so[Well_boundary[j-1,1]:Well_boundary[j+1,0]]
tmp =1.0/np.sum(wfh[:,0:n_max_general]**2/vb_meff,axis=1) #vb_meff[:,int(n_max/2)]
meff_state = tmp.tolist()
"""find subband effective masses including non-parabolicity
(but stilling using a fixed effective mass for each subband dispersion)"""
cb_meff = model.cb_meff # effective mass of conduction band across structure
cb_meff_alpha = model.cb_meff_alpha # non-parabolicity constant across structure
cb_meff_states = np.array([cb_meff*(1.0 + cb_meff_alpha*(E*meV2J - fi)) for E in E_statec])
tmp1 = 1.0/np.sum(wfe**2/cb_meff_states,axis=1)
meff_statec = tmp1.tolist()
return meff_statec,meff_state
def calc_meff_state(wfh,wfe,subnumber_h,subnumber_e,list,m_hh,m_lh,m_so):
n_max=len(m_hh)
vb_meff= np.zeros((subnumber_h,n_max))
#
for i in range(0,subnumber_h,1):
if list[i]=='hh' :
vb_meff[i]=m_hh
elif list[i] =='lh' :
vb_meff[i]=m_lh
else:
vb_meff[i]=m_so
tmp = 1.0/np.sum(wfh**2/vb_meff,axis=1)
meff_state = tmp.tolist()
"""find subband effective masses including non-parabolicity
(but stilling using a fixed effective mass for each subband dispersion)"""
cb_meff = model.cb_meff # effective mass of conduction band across structure
#cb_meff_alpha = model.cb_meff_alpha # non-parabolicity constant across structure
#cb_meff_states = np.array([cb_meff*(1.0 + cb_meff_alpha*(E*meV2J - fi)) for E in E_statec])
#tmp1 = 1.0/np.sum(wfe**2/cb_meff_states,axis=1)
tmp1 = 1.0/np.sum(wfe**2/cb_meff,axis=1)
meff_statec = tmp1.tolist()
return meff_statec,meff_state
def fermilevel_0Kc(Ntotal2d,E_statec,meff_statec,model):#use
Et2,Ef=0.0,0.0
meff_statec=np.array(meff_statec)
E_statec=np.array(E_statec)
for i in range (model.subnumber_e,0,-1): #,(Ei,vsb_meff) in enumerate(zip(E_state,meff_state)):
Efnew2=(sum(E_statec[0:i]*meff_statec[0:i]))
m2=(sum(meff_statec[0:i]))
Et2+=E_statec[i-model.subnumber_e]
Efnew=(Efnew2+Ntotal2d*hbar**2*pi*J2meV)/(m2)
if Efnew>Et2:
Ef=Efnew
#print 'Ef[',i-subnumber_h,']=',Ef
else:
break #we have found Ef and so we should break out of the loop
else: #exception clause for 'for' loop.
logger.warning("Have processed all energy levels present and so can't be sure that Ef is below next higher energy level.")
#Ef1=(sum(E_state*meff_state)-Ntotal2d*hbar**2*pi)/(sum(meff_state))
N_statec=[0.0]*len(E_statec)
for i,(Ei,csb_meff) in enumerate(zip(E_statec,meff_statec)):
Nic=(Ef - Ei)*csb_meff/(hbar**2*pi)*meV2J # populations of levels
Nic*=(Nic>0.0)
N_statec[i]=Nic
return Ef,N_statec #Fermi levels at 0K (meV), number of electrons in each subband at 0K
def fermilevel_0K(Ntotal2d,E_state,meff_state,model):#use
Et1,Ef=0.0,0.0
E_state=np.array(E_state)
for i in range (model.subnumber_h,0,-1): #,(Ei,vsb_meff) in enumerate(zip(E_state,meff_state)):
Efnew1=(sum(E_state[0:i]*meff_state[0:i]))
m1=(sum(meff_state[0:i]))
Et1+=E_state[i-model.subnumber_h]
Efnew=(Efnew1+Ntotal2d*hbar**2*pi*J2meV)/(m1)
if Efnew<Et1 :
Ef=Efnew
#print 'Ef[',i-subnumber_h,']=',Ef
else:
break #we have found Ef and so we should break out of the loop
else: #exception clause for 'for' loop.
logger.warning("Have processed all energy levels present and so can't be sure that Ef is below next higher energy level.")
#Ef1=(sum(E_state*meff_state)-Ntotal2d*hbar**2*pi)/(sum(meff_state))
N_state=[0.0]*len(E_state)
for i,(Ei,vsb_meff) in enumerate(zip(E_state,meff_state)):
Ni=(Ei - Ef)*vsb_meff/(hbar**2*pi)*meV2J # populations of levels
Ni*=(Ni>0.0)
N_state[i]=Ni
return Ef,N_state #Fermi levels at 0K (meV), number of electrons in each subband at 0K
def fermilevel(Ntotal2d,model,E_state,E_statec,meff_state,meff_statec):#use
#find the Fermi level (meV)
def func(Ef,E_state,meff_state,E_statec,meff_statec,Ntotal2d,model):
#return Ntotal2d - sum( [vsb_meff*fd2(Ei,Ef,T) for Ei,vsb_meff in zip(E_state,meff_state)] )/(hbar**2*pi)
diff,diff1,diff2=0.0,0.0,0.0
diff = Ntotal2d
for Ei,csb_meff in zip(E_statec,meff_statec):
diff1 -= csb_meff*fd2(Ei,Ef,model)/(hbar**2*pi)
for Ei,vsb_meff in zip(E_state,meff_state):
diff2 += vsb_meff*fd1(Ei,Ef,model)/(hbar**2*pi)
if Ntotal2d>0 :
diff+=diff1
else:
diff+=diff2
return diff
if Ntotal2d>0 :
Ef_0K,N_states_0K = fermilevel_0Kc(Ntotal2d,E_statec,meff_statec,model)
else:
Ef_0K,N_states_0K= fermilevel_0K(Ntotal2d,E_state,meff_state,model)
#Ef=fsolve(func,Ef_0K,args=(E_state,meff_state,Ntotal2d,T))[0]
#return float(Ef)
#implement Newton-Raphson method
Ef =Ef_0K
#itr=0
logger.info('Ef (at 0K)= %g',Ef)
d_E = 1e-9 #Energy step (meV)
while True:
y = func(Ef,E_state,meff_state,E_statec,meff_statec,Ntotal2d,model)
dy = (func(Ef+d_E,E_state,meff_state,E_statec,meff_statec,Ntotal2d,model)- func(Ef-d_E,E_state,meff_state,E_statec,meff_statec,Ntotal2d,model))/(2.0*d_E)
if dy == 0.0: #increases interval size for derivative calculation in case of numerical error
d_E*=2.0
continue
Ef -= y/dy
if abs(y/dy) < 1e-12:
break
for i in range(2):
if d_E>1e-9:
d_E*=0.5
return Ef #(meV)
def calc_N_state(Ef,model,E_state,meff_state,E_statec,meff_statec,Ntotal2d):#use
# Find the subband populations, taking advantage of step like d.o.s. and analytic integral of FD
N_statec,N_state=0.0,0.0
if Ntotal2d>0 :
N_statec=[fd2(Ei,Ef,model)*csb_meff/(hbar**2*pi) for Ei,csb_meff in zip(E_statec,meff_statec)]
else:
N_state=[fd1(Ei,Ef,model)*vsb_meff/(hbar**2*pi) for Ei,vsb_meff in zip(E_state,meff_state)]
return N_state,N_statec # number of carriers in each subband
# FUNCTIONS for SELF-CONSISTENT POISSON--------------------------------
def calc_sigma(wfh,wfe,N_state,N_statec,model,Ntotal2d): #use
"""This function calculates `net' areal charge density
n-type dopants lead to -ve charge representing electrons, and additionally
+ve ionised donors."""
# note: model.dop is still a volume density, the delta_x converts it to an areal density
sigma= model.dop*model.dx # The charges due to the dopant ions
if Ntotal2d>0 :
for j in range(0,model.subnumber_e,1): # The charges due to the electrons in the subbands
sigma-= N_statec[j]*(wfe[j])**2
else:
for i in range(0,model.subnumber_h,1): # The charges due to the electrons in the subbands
sigma+= N_state[i]*(wfh[i])**2
return sigma #charge per m**2 (units of electronic charge)
def calc_sigma_general(wfh,wfe,N_state,N_statec,model,Ntotal2d,j,Well_boundary): #use
"""This function calculates `net' areal charge density
n-type dopants lead to -ve charge representing electrons, and additionally
+ve ionised donors."""
# note: model.dop is still a volume density, the delta_x converts it to an areal density
sigma= model.dop[Well_boundary[j-1,1]:Well_boundary[j+1,0]]*model.dx # The charges due to the dopant ions
if Ntotal2d>0 :
for j in range(0,model.subnumber_e,1): # The charges due to the electrons in the subbands
sigma-= N_statec[j]*(wfe[j])**2
else:
for i in range(0,model.subnumber_h,1): # The charges due to the electrons in the subbands
sigma+= N_state[i]*(wfh[i])**2
return sigma #charge per m**2 (units of electronic charge)
##
def calc_field(sigma,eps):
# F electric field as a function of z-
# i index over z co-ordinates
# j index over z' co-ordinates
# Note: sigma is a number density per unit area, needs to be converted to Couloumb per unit area
sigma=sigma
F0 = -np.sum(q*sigma)/(2.0) #CMP'deki i ve j yer değişebilir - de + olabilir
# is the above necessary since the total field due to the structure should be zero.
# Do running integral
tmp = np.hstack(([0.0],sigma[:-1])) + sigma
tmp*= q/2.0 # Note: sigma is a number density per unit area, needs to be converted to Couloumb per unit area
tmp[0] = F0
F = np.cumsum(tmp)/eps
return F
def calc_field_convolve(sigma,eps):#use
tmp = np.ones(len(sigma)-1)
signstep = np.hstack((-tmp,[0.0],tmp)) # step function
F = np.convolve(signstep,sigma,mode='valid')
F*= q/(2.0*eps)
return F
def calc_field_old(sigma,eps):#use
# F electric field as a function of z-
# i index over z co-ordinates
# j index over z' co-ordinates
n_max = len(sigma)
# For wave function initialise F
F = np.zeros(n_max)
for i in range(0,n_max,1):
for j in range(0,n_max,1):
# Note sigma is a number density per unit area, needs to be converted to Couloumb per unit area
F[i] = F[i] + q*sigma[j]*cmp(i,j)/(2*eps[i]) #CMP'deki i ve j yer değişebilir - de + olabilir
return F
def calc_potn(F,model):#use
# This function calculates the potential (energy actually)
# V electric field as a function of z-
# i index over z co-ordinates
#Calculate the potential, defining the first point as zero
tmp = q*F*model.dx
V = np.cumsum(tmp) #+q -> electron -q->hole?
return V
# FUNCTIONS FOR EXCHANGE INTERACTION-------------------------------------------
def calc_Vxc(sigma,eps,cb_meff):
"""An effective field describing the exchange-interactions between the electrons
derived from Kohn-Sham density functional theory. This formula is given in many
papers, for example see Gunnarsson and Lundquist (1976), Ando, Taniyama, Ohtani
et al. (2003), or Ch.1 in the book 'Intersubband transitions in quantum wells' (edited
by Liu and Capasso) by M. Helm.
eps = dielectric constant array
cb_meff = effective mass array
sigma = charge carriers per m**2, however this includes the donor atoms and we are only
interested in the electron density."""
a_B = 4*pi*hbar**2/q**2 # Bohr radius.
nz= -(sigma - model.dop*model.dx) # electron density per m**2
nz_3 = nz**(1/3.) #cube root of charge density.
#a_B_eff = eps/cb_meff*a_B #effective Bohr radius
#r_s occasionally suffers from division by zero errors due to nz=0.
#We will fix these by setting nz_3 = 1.0 for these points (a tiny charge in per m**2).
nz_3 = nz_3.clip(1.0,max(nz_3))
r_s = 1.0/((4*pi/3.0)**(1/3.)*nz_3*eps/cb_meff*a_B) #average distance between charges in units of effective Bohr radis.
#A = q**4/(32*pi**2*hbar**2)*(9*pi/4.0)**(1/3.)*2/pi*(4*pi/3.0)**(1/3.)*4*pi*hbar**2/q**2 #constant factor for expression.
A = q**2/(4*pi)*(3/pi)**(1/3.) #simplified constant factor for expression.
#
Vxc = -A*nz_3/eps * ( 1.0 + 0.0545 * r_s * np.log( 1.0 + 11.4/r_s) )
return Vxc
# -----------------------------------------------------------------------------
# valence band effective-masses hh,lh
def Poisson_Schrodinger(model):
"""Performs a self-consistent Poisson-Schrodinger calculation of a 1d quantum well structure.
Model is an object with the following attributes:
fi - Bandstructure potential (J) (array, len n_max)
cb_meff - conduction band effective mass (kg)(array, len n_max)
eps - dielectric constant (including eps0) (array, len n_max)
dop - doping distribution (m**-3) ( array, len n_max)
Fapp - Applied field (Vm**-1)
T - Temperature (K)
comp_scheme - simulation scheme (currently unused)
subnumber_e - number of subbands for look for in the conduction band
dx - grid spacing (m)
n_max - number of points.
"""
fi = model.fi
cb_meff = model.cb_meff
eps = model.eps
dop = model.dop
Fapp = model.Fapp
T = model.T
comp_scheme = model.comp_scheme
subnumber_h = model.subnumber_h
N_wells_real0=model.N_wells_real0
subnumber_e = model.subnumber_e
dx = model.dx
n_max = model.n_max
mat_type= model.mat_type
if comp_scheme in (4,5,6):
logger.error("""aestimo_h doesn't currently include exchange interactions
in its valence band calculations.""")
exit()
if comp_scheme in (1,3,6):
logger.error("""aestimo_h doesn't currently include nonparabolicity effects in
its valence band calculations.""")
exit()
C11 = model.C11
C12 = model.C12
GA1 = model.GA1
GA2 = model.GA2
GA3 = model.GA3
Ac = model.Ac
Av = model.Av
B = model.B
a0 = model.a0
delta = model.delta
fi_h = model.fi_h
A1 = model.A1
A2 = model.A2
A3 = model.A3
A4 = model.A4
A5 = model.A5
A6 = model.A6
D1 = model.D1
D2 = model.D2
D3 = model.D3
D4 = model.D4
C13 = model.C13
C33 = model.C33
D31 = model.D31
D33 = model.D33
Psp = model.Psp
a0_wz = model.a0_wz
a0_sub = model.a0_sub
delta_so = model.delta_so
delta_cr = model.delta_cr
N_wells_virtual = model.N_wells_virtual
N_wells_virtual2 = model.N_wells_virtual2
Well_boundary=model.Well_boundary
Well_boundary2=model.Well_boundary2
barrier_boundary=model.barrier_boundary
Ppz= np.zeros(n_max)
HUPMAT1=np.zeros((n_max*3, n_max*3))
HUPMATC1=np.zeros((n_max, n_max))
UNIM = np.identity(n_max)
EXX = np.zeros(n_max)
EZZ = np.zeros(n_max)
ZETA= np.zeros(n_max)
CNIT= np.zeros(n_max)
VNIT= np.zeros(n_max)
S= np.zeros(n_max)
k1= np.zeros(n_max)
k2= np.zeros(n_max)
k3= np.zeros(n_max)
fp= np.ones(n_max)
fm= np.ones(n_max)
EPC= np.zeros(n_max)
m_hh = np.zeros(n_max)
m_lh = np.zeros(n_max)
m_so = np.zeros(n_max)
x_max=dx*n_max
if config.strain :
if mat_type=='Zincblende' :
EXX= (a0_sub-a0)/a0
EZZ= -2.0*C12/C11*EXX
ZETA= -B/2.0*(EXX+EXX-2.0*EZZ)
CNIT= Ac*(EXX+EXX+EZZ)
VNIT= -Av*(EXX+EXX+EZZ)
if mat_type=='Wurtzite':
EXX= (a0_sub-a0_wz)/a0_wz
EZZ=-2.0*C13/C33*EXX
CNIT= Ac*(EXX+EXX+EZZ)
ZETA= (D2*(EXX+EXX)+D1*EZZ)
VNIT= (D4*(EXX+EXX)+D3*EZZ)
Ppz=((D31*(C11+C12)+D33*C13)*(EXX+EXX)+(2*D31*C13+D33*C33)*(EZZ))
dx=x_max/n_max
sum_1=0.0
sum_2=0.0
if config.piezo:
""" spontaneous and piezoelectric polarization built-in field
[1] F. Bernardini and V. Fiorentini phys. stat. sol. (b) 216, 391 (1999)
[2] Book 'Quantum Wells,Wires & Dots', Paul Harrison, pages 236-241"""
for J in range(1,N_wells_virtual2-1):
BW=Well_boundary2[J,0]
WB=Well_boundary2[J,1]
Lw=(WB-BW)*dx
lb1=(BW-Well_boundary2[J-1,1])*dx
lb2=(Well_boundary2[J+1,0]-WB)*dx
sum_1+=(Psp[BW+1]+Ppz[BW+1])*Lw/eps[BW+1]+(Psp[BW-1]+Ppz[BW-1])*lb1/eps[BW-1]
sum_2+=Lw/eps[BW+1]+lb1/eps[BW-1]
EPC=(sum_1-(Psp+Ppz)*sum_2)/(eps*sum_2)
"""
sum_1=0.0
sum_2=0.0
sum_1=sum((Psp+Ppz)/eps)*dx
sum_2=sum(1/eps)*dx
EPC=(sum_1-(Psp+Ppz)*sum_2)/(eps*sum_2)
"""
if mat_type=='Zincblende' :
for i in range(0,n_max,1):
if EXX[i]!=0:
S[i]=ZETA[i]/delta[i]
k1[i]=sqrt(1+2*S[i]+9*S[i]**2)
k2[i]=S[i]-1+k1[i]
k3[i]=S[i]-1-k1[i]
fp[i]=(2*S[i]*(1+1.5*k2[i])+6*S[i]**2)/(0.75*k2[i]**2+k2[i]-3*S[i]**2)
fm[i]=(2*S[i]*(1+1.5*k3[i])+6*S[i]**2)/(0.75*k3[i]**2+k3[i]-3*S[i]**2)
m_hh = m_e/(GA1 -2*GA2 )
m_lh = m_e/(GA1 +2*fp*GA2 )
m_so = m_e/(GA1 +2*fm*GA2 )
if mat_type=='Wurtzite' :
m_hh = -m_e/(A2 + A4 -A5)
m_lh = -m_e/(A2 + A4 +A5 )
m_so = -m_e/(A2)
RATIO=m_e/hbar**2*(x_max)**2
AC1=(n_max+1)**2
AP1,AP2,AP3,AP4,AP5,AP6,FH,FL,FSO,Pce,GDELM,DEL3,DEL1,DEL2=qsv(GA1,GA2,GA3,RATIO,VNIT,ZETA,CNIT,AC1,n_max,delta,A1,A2,A3,A4,A5,A6,delta_so,delta_cr,mat_type)
KP=0.0
KPINT=0.01
if mat_type=='Zincblende' :
HUPMAT1=VBMAT1(KP,AP1,AP2,AP3,AP4,AP5,AP6,FH,FL,FSO,GDELM,x_max,n_max,AC1,UNIM,KPINT)
if mat_type=='Wurtzite' :
HUPMAT1=-VBMAT2(KP,AP1,AP2,AP3,AP4,AP5,AP6,FH,FL,x_max,n_max,AC1,UNIM,KPINT,DEL3,DEL1,DEL2)
HUPMATC1=CBMAT(KP,Pce,cb_meff/m_e,x_max,n_max,AC1,UNIM,KPINT)
def calc_E_state(HUPMAT1,HUPMATC1,subnumber_h,subnumber_e,fitot,fitotc):
HUPMAT3=np.zeros((n_max*3, n_max*3))
HUPMAT3=VBMAT_V(HUPMAT1,fitot,RATIO,n_max,UNIM)
HUPMATC3=CBMAT_V(HUPMATC1,fitotc,RATIO,n_max,UNIM)
#stop
KPV1=[0.0]*subnumber_e
la1,v1= linalg.eigh(HUPMATC3)
tmp1=la1/RATIO*J2meV
tmp1=tmp1.tolist()
for i in range(0,subnumber_e,1):
KPV1[i]=tmp1[i]
KPV2=[0.0]*subnumber_h
la2,v2= linalg.eigh(HUPMAT3)
tmp=-la2/RATIO*J2meV
tmp=tmp.tolist()
for i in range(0,subnumber_h,1):
KPV2[i]=tmp[i]
return KPV1,v1,KPV2,v2
KPV1=np.zeros((model.N_wells_virtual,subnumber_e))
V1=np.zeros((model.N_wells_virtual,n_max,n_max))
KPV2=np.zeros((model.N_wells_virtual,subnumber_h))
V2=np.zeros((model.N_wells_virtual,n_max*3,n_max*3))
n_max_general=np.zeros(model.N_wells_virtual,dtype=int)
def calc_E_state_general(HUPMAT1,HUPMATC1,subnumber_h,subnumber_e,fitot,fitotc,model,Well_boundary):
n_max_general=np.zeros(model.N_wells_virtual)
HUPMAT3=np.zeros((n_max*3, n_max*3))
HUPMAT3=VBMAT_V(HUPMAT1,fitot,RATIO,n_max,UNIM)
HUPMATC3=CBMAT_V(HUPMATC1,fitotc,RATIO,n_max,UNIM)
#stop
tmp1=np.zeros((model.N_wells_virtual,n_max))
KPV1=np.zeros((model.N_wells_virtual,subnumber_e))
V1=np.zeros((model.N_wells_virtual,n_max,n_max))
for J in range(1,model.N_wells_virtual-1):
n_max_general[J]=Well_boundary[J+1,0]-Well_boundary[J-1,1]
I1=Well_boundary[J-1,1]
I2=Well_boundary[J+1,0]
i1=I1-I1
i2=I2-I1
la1,v1= linalg.eigh(HUPMATC3[I1:I2,I1:I2])
tmp1[J,i1:i2]=la1/RATIO*J2meV
V1[J,i1:i2,i1:i2]=v1
for j in range(1,model.N_wells_virtual-1):
for i in range(0,subnumber_e,1):
KPV1[j,i]=tmp1[j,i]
tmp=np.zeros((model.N_wells_virtual,n_max*3))
KPV2=np.zeros((model.N_wells_virtual,subnumber_h))
V2=np.zeros((model.N_wells_virtual,n_max*3,n_max*3))
for k in range(1,model.N_wells_virtual-1):
i_1=int(n_max_general[k])
HUPMAT3_general=np.zeros((i_1*3,i_1*3))
I1=Well_boundary[k-1,1]
I2=Well_boundary[k+1,0]
i1=I1-I1
i2=I2-I1
HUPMAT3_general[i1:i2,i1:i2]=HUPMAT3[I1:I2,I1:I2]
HUPMAT3_general[i1+i_1:i2+i_1,i1:i2]=HUPMAT3[I1+n_max:I2+n_max,I1:I2]
HUPMAT3_general[i1:i2,i1+i_1:i2+i_1]=HUPMAT3[I1:I2,I1+n_max:I2+n_max]
HUPMAT3_general[i1+i_1:i2+i_1,i1+i_1:i2+i_1]=HUPMAT3[I1+n_max:I2+n_max,I1+n_max:I2+n_max]
HUPMAT3_general[i1+i_1*2:i2+i_1*2,i1:i2]=HUPMAT3[I1+n_max*2:I2+n_max*2,I1:I2]
HUPMAT3_general[i1:i2,i1+i_1*2:i2+i_1*2]=HUPMAT3[I1:I2,I1+n_max*2:I2+n_max*2]
HUPMAT3_general[i1+i_1*2:i2+i_1*2,i1+i_1*2:i2+i_1*2]=HUPMAT3[I1+n_max*2:I2+n_max*2,I1+n_max*2:I2+n_max*2]
HUPMAT3_general[i1+i_1:i2+i_1,i1+i_1*2:i2+i_1*2]=HUPMAT3[I1+n_max:I2+n_max,I1+n_max*2:I2+n_max*2]
HUPMAT3_general[i1+i_1*2:i2+i_1*2,i1+i_1:i2+i_1]=HUPMAT3[I1+n_max*2:I2+n_max*2,I1+n_max:I2+n_max]
la2,v2= linalg.eigh(HUPMAT3_general)
tmp[k,i1:i2*3]=-la2/RATIO*J2meV
V2[k,i1:i2*3,i1:i2*3]=v2
#tmp=tmp.tolist()
for j in range(1,model.N_wells_virtual-1):
for i in range(0,subnumber_h,1):
KPV2[j,i]=tmp[j,i]
return KPV1,V1,KPV2,V2
# Check
if comp_scheme ==6:
logger.warning("""The calculation of Vxc depends upon m*, however when non-parabolicity is also
considered m* becomes energy dependent which would make Vxc energy dependent.
Currently this effect is ignored and Vxc uses the effective masses from the
bottom of the conduction bands even when non-parabolicity is considered
elsewhere.""")
# Preparing empty subband energy lists.
E_state = [0.0]*subnumber_h # Energies of subbands/levels (meV)
N_state = [0.0]*subnumber_h # Number of carriers in subbands
E_statec = [0.0]*subnumber_e # Energies of subbands/levels (meV)
N_statec = [0.0]*subnumber_e # Number of carriers in subbands
# Preparing empty subband energy arrays for multiquantum wells.
E_state_general = np.zeros((model.N_wells_virtual,subnumber_h)) # Energies of subbands/levels (meV)
N_state_general = np.zeros((model.N_wells_virtual,subnumber_h)) # Number of carriers in subbands
E_statec_general = np.zeros((model.N_wells_virtual,subnumber_e)) # Energies of subbands/levels (meV)
N_statec_general = np.zeros((model.N_wells_virtual,subnumber_e)) # Number of carriers in subbands
meff_statec_general= np.zeros((model.N_wells_virtual,subnumber_e))
meff_state_general= np.zeros((model.N_wells_virtual,subnumber_h))
# Creating and Filling material arrays
xaxis = np.arange(0,n_max)*dx #metres
fitot = np.zeros(n_max) #Energy potential = Bandstructure + Coulombic potential
fitotc = np.zeros(n_max) #Energy potential = Bandstructure + Coulombic potentia
#eps = np.zeros(n_max+2) #dielectric constant
#dop = np.zeros(n_max+2) #doping distribution
#sigma = np.zeros(n_max+2) #charge distribution (donors + free charges)
#F = np.zeros(n_max+2) #Electric Field
#Vapp = np.zeros(n_max+2) #Applied Electric Potential
V = np.zeros(n_max) #Electric Potential
# Subband wavefunction for holes list. 2-dimensional: [i][j] i:stateno, j:wavefunc
wfh = np.zeros((subnumber_h,n_max))
wfe = np.zeros((subnumber_e,n_max))
wfh_general = np.zeros((model.N_wells_virtual,subnumber_h,n_max))
wfe_general = np.zeros((model.N_wells_virtual,subnumber_e,n_max))
E_F_general= np.zeros(model.N_wells_virtual)
sigma_general = np.zeros(n_max)
F_general = np.zeros(n_max)
Vnew_general = np.zeros(n_max)
# Setup the doping
Ntotal = sum(dop) # calculating total doping density m-3
Ntotal2d = Ntotal*dx
if not(config.messagesoff):
#print "Ntotal ",Ntotal,"m**-3"
logger.info("Ntotal2d %g m**-2", Ntotal2d)
#Applied Field
Vapp = calc_potn(Fapp*eps0/eps,model)