Skip to content
Extraits de code Groupes Projets
transistor.py 1,23 ko
Newer Older
  • Learn to ignore specific revisions
  • import data_processing as proc 
    import numpy as np
    import scipy.interpolate as interp
    
    def threshold_voltage_extraction(i,v,smoothing=True,accuracy=6): # second-derivative method
        v_step=np.mean(v[1:]-v[:-1])
        
        gm,v_gm=proc.finite_difference(i, v_step,order=2,accuracy=accuracy)
        
        f = interp.InterpolatedUnivariateSpline(v_gm, gm, k=4)
        cr_pts = f.derivative().roots()
        cr_pts = np.append(cr_pts, (v_gm[0], v_gm[-1]))  # also check the endpoints of the interval
        cr_vals = f(cr_pts)
        max_index = np.argmax(cr_vals)
        vth=cr_pts[max_index]
        gm_max=cr_vals[max_index]
        
        return vth, gm_max
        
    def mos_transistor_current(vg,vd,vs=0,vth=0.8,k=1e-4,vea=50,mos_type="nmos",early=True):
        if mos_type=="nmos":
            vth=abs(vth)
            vds=vd-vs
            vgs=vg-vs
        if mos_type=="pmos":
            vth=abs(vth)
            vds=vs-vd
            vgs=vs-vg
            
        if vgs<vth:
            mode="cutoff"
        elif vgs>=vds:
            mode="saturation"
        elif vg-vs<vds:
            mode="triode"
    
        if mode=="cutoff":
            jd=0
        elif mode=="saturation":
            jd=k/2*(vgs-vth)**2
        
        elif mode=="triode":
            jd=k*((vgs-vth)*(vds)-(vds)**2/2)
    
        if early:
            return jd*(1+(vds)/vea)
        else:
            return jd