IHP SG13G2 HBT test

include "sg13g2_vacask_common.lib"
include "cornerHBT.lib" section=hbt_typ

model v vsource
vbe (b 0) v dc=0
vce (c 0) v dc=0
  
subckt npn13g2test()
  q1 (c b 0 0) npn13G2
ends

subckt npn13g2ltest()
  q1 (c b 0 0) npn13G2l
ends

subckt npn13g2vtest()
  q1 (c b 0 0) npn13G2v
ends

subckt pnpmpatest()
  q1 (c b 0) pnpMPA
ends


control
  print device("vbic13_5t")
  
  elaborate circuit("npn13g2test")
  print instance("q1")
  sweep vbe instance="vbe" parameter="dc" from=0.65 to=1.00 step=0.05
  sweep vce instance="vce" parameter="dc" from=0 to=2 step=0.01 
    analysis opnpn13g2 op
  
  elaborate circuit("npn13g2ltest")
  print instance("q1")
  sweep vbe instance="vbe" parameter="dc" from=0.65 to=1.04 step=0.05
  sweep vce instance="vce" parameter="dc" from=0 to=2 step=0.01
    analysis opnpn13g2l op

  elaborate circuit("npn13g2vtest")
  print instance("q1")
  sweep vbe instance="vbe" parameter="dc" from=0.65 to=1.0 step=0.05
  sweep vce instance="vce" parameter="dc" from=0 to=3 step=0.01
    analysis opnpn13g2v op

  elaborate circuit("pnpmpatest")
  print instance("q1")
  sweep vbe instance="vbe" parameter="dc" from=-0.65 to=-1.0 step=-0.05
  sweep vce instance="vce" parameter="dc" from=-0.23 to=-3 step=-0.01
    analysis oppnpmpa op

  postprocess(PYTHON, "runme.py")
endc

embed "runme.py" <<<FILE
from rawfile import rawread
import numpy as np
import matplotlib.pyplot as plt

fig1 = plt.figure(figsize=(8,8), dpi=100)
fig1.suptitle('IHP SG13G2 HBT test')
ax_dict = fig1.subplot_mosaic("""
AB
CD
""")

ax_dict["A"].set_title('npn13g2')
ax_dict["A"].set_ylabel('Ic [uA]')
ax_dict["A"].set_xlabel('Vce [V]')

raw = rawread('opnpn13g2.raw')
plot = raw.get(sweeps=1)

for ii in range(plot.sweepGroups):
    sdata = plot.sweepData(ii)
    # print(sdata)
    traceName = 'vbe=%.2e' % sdata['vbe']
    ax_dict["A"].plot(plot[ii, 'c'], -plot[ii, 'vce:flow(br)']*1e6, label=traceName)
    
ax_dict["A"].legend(loc='upper right')


ax_dict["B"].set_title('npn13g2l')
ax_dict["B"].set_ylabel('Ic [uA]')
ax_dict["B"].set_xlabel('Vce [V]')

raw = rawread('opnpn13g2l.raw')
plot = raw.get(sweeps=1)

for ii in range(plot.sweepGroups):
    sdata = plot.sweepData(ii)
    # print(sdata)
    traceName = 'vbe=%.2e' % sdata['vbe']
    ax_dict["B"].plot(plot[ii, 'c'], -plot[ii, 'vce:flow(br)']*1e6, label=traceName)
    
ax_dict["B"].legend(loc='upper right')


ax_dict["C"].set_title('npn13g2v')
ax_dict["C"].set_ylabel('Ic [uA]')
ax_dict["C"].set_xlabel('Vce [V]')

raw = rawread('opnpn13g2v.raw')
plot = raw.get(sweeps=1)

for ii in range(plot.sweepGroups):
    sdata = plot.sweepData(ii)
    # print(sdata)
    traceName = 'vbe=%.2e' % sdata['vbe']
    ax_dict["C"].plot(plot[ii, 'c'], -plot[ii, 'vce:flow(br)']*1e6, label=traceName)
    
ax_dict["C"].legend(loc='upper right')


ax_dict["D"].set_title('pnpmpa')
ax_dict["D"].set_ylabel('Ic [uA]')
ax_dict["D"].set_xlabel('Vce [V]')

raw = rawread('oppnpmpa.raw')
plot = raw.get(sweeps=1)

for ii in range(plot.sweepGroups):
    sdata = plot.sweepData(ii)
    # print(sdata)
    traceName = 'vbe=%.2e' % sdata['vbe']
    ax_dict["D"].plot(plot[ii, 'c'], -plot[ii, 'vce:flow(br)']*1e6, label=traceName)

yl = ax_dict["D"].get_ylim()
ax_dict["D"].set_ylim([yl[0], np.abs(yl[0])/20])
ax_dict["D"].legend(loc='lower left')

fig1.tight_layout()
 
plt.show()
>>>FILE


