def test_get_energy(self): bracket = (from_unit(70, 'meV'), from_unit(72, 'meV')) self.assertAlmostEqual( self.model.get_energy(1 / self.model.period, self.mass, bracket, unit('ueV')) / unit('meV'), 71.2, delta=0.1)
def test_get_energy(self): bracket = (from_unit(935, 'ueV'), from_unit(940, 'ueV')) self.assertAlmostEqual( self.model.get_energy(1 / self.model.period, self.mass, bracket, unit('ueV')) / unit('ueV'), 935.6, delta=0.1)
def test_concentration(self): self.assertAlmostEqual(concentration(0.01 * unit('Ohm cm'), self.mobility), 1.2e18, delta=1e17) self.assertAlmostEqual(concentration(10000 * unit('Ohm cm'), self.mobility), 1.2e12, delta=1e11)
def test_Id_sat(self): jfet = JFET(Si, 1e17, from_unit(1400, 'cm^2 /V s'), from_unit(1, 'um'), from_unit(1, 'um'), from_unit(10, 'um')) self.assertAlmostEqual( jfet.Id_sat(from_unit(5, 'V'), from_unit(1, 'V')) / unit('mA'), 9.3, delta=0.1)
def test_full_depletion_width(self): # The parameters are selected to comply with the condition delta_phi = 0.5 volt c = MSJunction(Metal(4.65 * eV), DopedSemiconductor(Si, 0, 0, 1e17, Si.Eg)) self.assertAlmostEqual(c.delta_phi() / volt, 0.5, delta=0.001) self.assertAlmostEqual(c.full_depletion_width() / unit('nm'), 81, delta=1)
def test_current(self): n = p = 1e17 pn = PNJunctionNonDegenerate(Si, n, 0, p, Si.Eg) d_n = 36 d_p = 12 l_n = l_p = 1e-2 voltage = 0.8 * volt jp = pn.current_p(d_p, l_p, voltage) jn = pn.current_n(d_n, l_n, voltage) self.assertAlmostEqual((jp + jn) / unit('A / cm2'), 2.5, delta=0.1) voltage = -100 * volt jp = pn.current_p(d_p, l_p, voltage) jn = pn.current_n(d_n, l_n, voltage) self.assertAlmostEqual((jp + jn) / unit('A / cm2'), -9.4e-14, delta=0.1e-14) # -J_0
def test_j0(self): n = p = 1e17 pn = PNJunctionNonDegenerate(Si, n, 0, p, Si.Eg) d_n = 36 d_p = 12 l_n = l_p = 1e-2 j0p = pn.j0_p(d_p, l_p) j0n = pn.j0_n(d_n, l_n) self.assertAlmostEqual((j0p + j0n) / unit('A / cm^2'), 9.4e-14, delta=0.1e-14)
def setUp(self): self.mobility = 500 * unit('cm2 / V s')
def test_Ip(self): jfet = JFET(Si, 1e17, from_unit(1400, 'cm^2 /V s'), from_unit(1, 'um'), from_unit(1, 'um'), from_unit(10, 'um')) self.assertAlmostEqual(jfet.Ip() / unit('mA'), 11.5, delta=0.1)
def test_Vp(self): jfet = JFET(Si, 1e17, from_unit(1400, 'cm^2 /V s'), from_unit(1, 'um'), from_unit(1, 'um'), from_unit(10, 'um')) self.assertAlmostEqual(jfet.Vp() / unit('V'), 77.32, delta=0.01)
def test_convenience_methods(self): self.assertEqual(to_unit(1, 'V'), 1 / unit('V')) self.assertEqual(from_unit(1, 'V'), 1 * unit('V'))
def test_lowest_band(self): r = self.model.find_lower_band_range(self.mass, 1e-8 * eV, 1e-10 * eV) self.assertLessEqual(r[0] / eV, r[1] / eV) self.assertAlmostEqual(r[0] / unit('meV'), 0, delta=1e-3) self.assertAlmostEqual(r[1] / unit('meV'), 0, delta=1e-3)
def test_power(self): self.assertEqual(unit('kg^2'), 1e6) self.assertEqual(unit('kg^2/2'), 1e3) self.assertEqual(unit('kg^2/2 / 1'), 1e3) self.assertEqual(unit('kg^4/2 / kg'), 1e3) self.assertEqual(unit('1 / kg^-2'), 1e6)
def test_prefixes(self): self.assertEqual(unit('dam'), 1e3) self.assertEqual(unit('dm'), 1e1) self.assertEqual(unit('dA'), ampere / 10)
def test_volt(self): self.assertAlmostEqual(unit('V-1'), 300, delta=1) self.assertAlmostEqual(unit('1 / V'), 300, delta=1)
import matplotlib.pyplot as plt import numpy as np from fompy.constants import eV from fompy.materials import Si from fompy.models import DopedSemiconductor, conductivity from fompy.units import unit from irwin.materials import Material MOBILITY_UNIT = unit('cm^2 / V s') RESISTIVITY_UNIT = unit('Ohm cm') CONCENTRATION_UNIT = unit('cm-3') A_UNIT = unit('cm^2 K^3/2 / V s') B_UNIT = unit('K^3') def mobility(mat, T, A, B): """ A mobility(T; Nd, Na; A, B) = -------------------------- 3/2 3/2 T + B * (Nd + Na) / T """ Nd = mat.p_donor_concentration(T=T) Na = mat.n_acceptor_concentration(T=T) T32 = T**(3 / 2) return A / (T32 + B * (Nd + Na) / T32) def resistivity(mat, Na, Ea, Nd, Ed, T): """Вычисляет сопротивление по концентрациям в функции irwin написано тоже самое но *немного* оптимальнее"""
from fompy.materials import Si, Ge from fompy.units import unit A_UNIT = unit('cm^2 K^3/2 / V s') B_UNIT = unit('K^3') class Material: def __init__(self, semiconductor, mobility_const_a, mobility_const_b): self.semiconductor = semiconductor self.mobility_const_a = mobility_const_a self.mobility_const_b = mobility_const_b # For n-conductivity_type N_MATERIALS = { 'Si': Material(Si, 4.476183e+06 * A_UNIT, 1.592302e-12 * B_UNIT), 'Ge': Material(Ge, 1.018281e+07 * A_UNIT, 1.071256e-11 * B_UNIT), 'GaAs': Material(Ge, 4.833961e+07 * A_UNIT, 1.069558e-10 * B_UNIT) } # For p-conductivity_type P_MATERIALS = { 'Si': Material(Si, 2.413845e+06 * A_UNIT, 1.223030e-12 * B_UNIT), 'Ge': Material(Ge, 4.402371e+06 * A_UNIT, 9.567049e-12 * B_UNIT) }
def test_debye_length(self): c = MSJunction(Metal(4.1 * eV), DopedSemiconductor(Si, 0, 0, 1e18, Si.Eg)) self.assertAlmostEqual(c.debye_length() / unit('nm'), 4.4, delta=0.1)
def test_underscore(self): self.assertEqual(unit('eV_T'), eV_T) self.assertEqual(unit('eV_m'), eV_m) self.assertEqual(unit('meV_T'), eV_T / 1000) self.assertEqual(unit('MeV_m'), eV_m * 1e6)
class Units: RESISTIVITY = unit('Ohm cm') CONDUCTIVITY = unit('1 / Ohm cm') CONCENTRATION = unit('cm-3') RESISTIVITY_TEXT = r'$Ohm \cdot cm$' CONDUCTIVITY_TEXT = r'$\frac{1}{Ohm \cdot cm}$'
def test_conductivity(self): resistivity = 1 / conductivity(1e18, self.mobility) self.assertAlmostEqual(resistivity / unit('Ohm cm'), 0.012, delta=0.001)
import csv import matplotlib.pyplot as plt import numpy as np from fompy.materials import Si from fompy.models import DopedSemiconductor from fompy.units import unit from scipy.optimize import curve_fit MOBILITY_UNIT = unit('cm^2 / V s') A_UNIT = unit('cm^2 K^3/2 / V s') B_UNIT = unit('K^3') class Line: def __init__(self, xs, ys, mat, color, label): self.xs = np.array(list(xs)) self.ys = np.array(list(ys)) self.mat = mat self.color = color self.label = label def get_lines(filename, desc): line = None lines = dict() with open(filename, 'r') as f: reader = csv.reader(f) for r in reader: if len(r) == 0: continue
from math import pi import matplotlib import matplotlib.pyplot as plt import numpy as np from fompy.constants import eV, me from fompy.models import KronigPenneyModel, DiracCombModel from fompy.units import unit matplotlib.rc('axes.formatter', useoffset=False) if __name__ == '__main__': m = 0.49 * me U0 = -0.58 * eV # '-' потенцияальная яма a = 1 * unit('nm') b = 200 * unit('nm') kp_model = KronigPenneyModel(a, b, U0) dc_model = DiracCombModel(a + b, a * U0) es = np.linspace(-0.001 * eV, 0.001 * eV, 100000) ks = kp_model.get_ks(es, m) # Array of k * (a+b) plt.plot(ks, es / eV, label='Kronig-Penney') ks = dc_model.get_ks(es, m) plt.plot(ks, es / eV, label='Dirac comb') plt.axhline(0, color='k', linestyle='--') plt.xlim(0, pi)