# NMOS Case
go atlas
#
set Lg=0.1 # length of Gate
set Lsd=0.1 # length of source and drain
set Ldd=0.04
set Tpoly=-0.2
set Tox=-0.003 # thickness of oxide
set Nwell=2e+17
set Nvt=2e+18 # for Gate
set Nldd=6e+18
set Nsd=7e+19 # N doping of source and drain

#define Mesh
mesh space.mult=1.0
x.mesh loc=0.0 spac=0.10
x.mesh loc=$"Lsd" spac=0.06
x.mesh loc=$"Lsd"+$"Ldd" spac=0.02
x.mesh loc=$"Lsd"+$"Ldd"+($"Lg"*0.5) spac=0.02
x.mesh loc=$"Lsd"+$"Ldd"+($"Lg"*0.5) spac=0.02
x.mesh loc=$"Lsd"+$"Ldd"+$"Lg" spac=0.02
x.mesh loc=$"Lsd"+($"Ldd"*2)+$"Lg" spac=0.06
x.mesh loc=($"Lsd"*2)+($"Ldd"*2)+$"Lg" spac=0.10

y.mesh loc=$"Tpoly" spac=0.004
y.mesh loc=$"Tox" spac=0.003
y.mesh loc=0.0 spac=0.002
y.mesh loc=0.2 spac=0.005
y.mesh loc=0.5 spac=0.05
y.mesh loc=1 spac=0.15

#Define regions
REGION number=1 NAME=Silicon y.min=0 material=Silicon
REGION number=2 NAME=airr y.max=0 material=air
REGION number=3 NAME=Spacer x.min=$"Lsd" x.max=$"Lsd"+($"Ldd"*2)+$"Lg" y.min= $"Tpoly" y.max=0 material=Nitride
REGION number=4 NAME=gateoxide x.min=$"Lsd" x.max=$"Lsd"+($"Ldd"*2)+$"Lg" y.min=$"Tox" y.max=0 material=SiO2
REGION number=5 NAME=gatepoly x.min=$"Lsd"+$"Ldd" x.max=$"Lsd"+$"Ldd"+$"Lg" y.min=$"Tpoly"  y.max=$"Tox" material=Poly
REGION number=6 NAME=alelectrode x.min=0 x.max=$"Lsd" y.min=$"Tpoly" y.max=0 material=Aluminum
REGION number=7 NAME=alelectrode x.min=$"Lsd"+$"Ldd"*2+$"Lg" x.max= $"Lsd"*2+$"Ldd"*2+$"Lg"  y.min= $"Tpoly" y.max=0 material=Aluminum

#Define electrode
electrode number=1 name=source x.min=0 x.max=$"Lsd" y.min=$"Tpoly" y.max=0
electrode number=2 name=drain x.min=$"Lsd"+($"Ldd"*2)+$"Lg" x.max=($"Lsd"*2)+($"Ldd"*2)+$"Lg" y.min=$Tpoly  y.max=0
electrode number=3 name=gate x.min=$"Lsd"+$"Ldd" x.max=$"Lsd"+$"Ldd"+$"Lg" y.min=$Tpoly y.max=$Tox
electrode number=4 name=base Bottom

#Define doping

#
doping uniform conc=$"Nwell" p.type direction=y
#
doping uniform conc=$"Nvt" p.type x.left=$"Lsd"+$"Ldd" x.right=$"Lsd"+$"Ldd"+$"Lg" y.top=0 y.bottom=0.06 direction=y
#
doping uniform conc=$"Nldd" n.type x.left=0 x.right=$"Lsd"+$"Ldd" y.top=0 y.bottom=0.04 direction=y
#
doping uniform conc=$"Nldd" n.type x.left=$"Lsd"+$"Ldd"+$"Lg" x.right= ($"Lsd"*2)+($"Ldd"*2)+$"Lg"  y.top=0 y.bottom=0.04 direction=y
#
doping uniform conc=$"Nsd" n.type x.left=0 x.right=$"Lsd" y.top=0 y.bottom=0.1  direction=y
#
doping uniform conc=$"Nsd" n.type x.left=$"Lsd"+($"Ldd"*2)+$"Lg" x.right=($"Lsd"*2)+($"Ldd"*2)+$"Lg" y.top=0 y.bottom=0.1 direction=y

# save structure
SAVE outfile=NMOS.str

#NMOS IDVG curve
go atlas
set Vd=1
set Vg=2
# IDVG (Vd = 1)
MESH infile=NMOS.str  space.mult=1.0
# Specify models
#MODELS   MOS PRINT  SRH  BGN  BTBT  TEMP=300
models srh cvt print BTBT temperature=300 
# Set the workfunction of the Poly gate
CONTACT NAME=gate N.POLY
# IDVG curve
METHOD  DAMPED  NEWTON  CARRIERS=2
SOLVE   initial
#
solve vdrain=0 vstep=0.1 vfinal=$"Vd" name=drain
solve vgate=0 vstep=-0.1 vfinal=-1 name=gate
LOG outfile=NMOS_IDVG_Vd$"Vd".log master
solve vgate=-1 vstep=0.05 vfinal=$"Vg" name=gate
#
log off
SAVE outfile=NMOS_IDVG_Vd$"Vd".str
OUTPUT CON.BAND VAL.BAND
SAVE outfile=NMOS_IDVG_Vd$"Vd"_Band.str

#
extract name="vt" (xintercept(maxslope(curve(abs(v."gate"),abs(i."drain")))) - abs(ave(v."drain"))/2.0)
extract name="subvt" 1.0/slope(maxslope(curve(abs(v."gate"),log10(abs(i."drain")))))
#

set Vd123=2
set Vg1=1
set Vg2=0.8
set Vg3=0.6
# IDVD curve (Vg = 1)
METHOD  DAMPED  NEWTON  CARRIERS=2
#
SOLVE   initial 
#
solve vgate=0 vstep=0.1 vfinal=$"Vg1" name=gate
LOG outfile=NMOS_IDVD_Vg$"Vg1".log master
solve vdrain=0 vstep=0.05 vfinal=$"Vd123" name=drain
log off
SAVE outfile=NMOS_IDVD_Vg$"Vg1".str
OUTPUT CON.BAND VAL.BAND
SAVE outfile=NMOS_IDVD_Vg$"Vg1"_Band.str
###
# IDVD curve (Vg = 0.8)
METHOD  DAMPED  NEWTON  CARRIERS=2
#
SOLVE   initial 
#
solve vgate=0 vstep=0.1 vfinal=$"Vg2" name=gate
LOG outfile=NMOS_IDVD_Vg$"Vg2".log master
solve vdrain=0 vstep=0.05 vfinal=$"Vd123" name=drain
log off
SAVE outfile=NMOS_IDVD_Vg$"Vg2".str
OUTPUT CON.BAND VAL.BAND
SAVE outfile=NMOS_IDVD_Vg$"Vg2"_Band.str
###
# IDVD curve (Vg = 0.6)
METHOD  DAMPED  NEWTON  CARRIERS=2
#
SOLVE   initial 
#
solve vgate=0 vstep=0.1 vfinal=$"Vg3" name=gate
LOG outfile=NMOS_IDVD_Vg$"Vg3".log master
solve vdrain=0 vstep=0.05 vfinal=$"Vd123" name=drain
log off
SAVE outfile=NMOS_IDVD_Vg$"Vg3".str
OUTPUT CON.BAND VAL.BAND
SAVE outfile=NMOS_IDVD_Vg$"Vg3"_Band.str

