v {xschem version=3.4.8RC file_version=1.3}
G {}
K {}
V {}
S {}
F {}
E {}
L 4 30 300 220 300 {}
L 4 220 300 220 420 {}
L 4 30 420 220 420 {}
L 4 30 300 30 420 {}
L 4 710 190 900 190 {}
L 4 900 190 900 310 {}
L 4 710 310 900 310 {}
L 4 710 190 710 310 {}
T {@#0:pinnumber} 503.75 225 3 1 0.2 0.2 {layer=13
name=Co1}
T {@#1:pinnumber} 546.25 225 3 1 0.2 0.2 {layer=13
name=Co1}
T {@name} 525 191.25 0 0 0.2 0.2 {name=Co1}
T {@value} 525 233.75 0 0 0.2 0.2 {name=Co1}
T {@spice_get_current} 535 222.5 3 1 0.2 0.2 {layer=17
name=Co1}
T {@#0:pinnumber} 603.75 225 3 1 0.2 0.2 {layer=13
name=Co2}
T {@#1:pinnumber} 646.25 225 3 1 0.2 0.2 {layer=13
name=Co2}
T {@name} 625 191.25 0 0 0.2 0.2 {name=Co2}
T {@value} 625 233.75 0 0 0.2 0.2 {name=Co2}
T {@spice_get_current} 635 222.5 3 1 0.2 0.2 {layer=17
name=Co2}
T {@#0:pinnumber} 586.25 50 1 1 0.2 0.2 {layer=13
name=R1}
T {@#1:pinnumber} 543.75 50 1 1 0.2 0.2 {layer=13
name=R1}
T {@name} 565 48.75 2 0 0.2 0.2 {name=R1}
T {@value} 565 86.25 2 0 0.2 0.2 {name=R1}
T {m=@m} 565 103.75 2 0 0.2 0.2 {name=R1}
T {@spice_get_current} 555 50 1 1 0.2 0.2 {layer=17
name=R1}
T {@name} 275 168.75 2 0 0.2 0.2 {name=R4}
T {@#0:pinnumber} 296.25 170 1 1 0.2 0.2 {layer=13
name=R4}
T {@#1:pinnumber} 253.75 180 1 1 0.2 0.2 {layer=13
name=R4}
T {@value} 275 206.25 2 0 0.2 0.2 {name=R4}
T {m=@m} 285 223.75 2 0 0.2 0.2 {name=R4}
T {@spice_get_current} 265 180 1 1 0.2 0.2 {layer=17
name=R4}
T {@name} 175 168.75 2 0 0.2 0.2 {name=R3}
T {@#0:pinnumber} 196.25 170 1 1 0.2 0.2 {layer=13
name=R3}
T {@#1:pinnumber} 153.75 170 1 1 0.2 0.2 {layer=13
name=R3}
T {@name} 175 168.75 2 0 0.2 0.2 {name=R3}
T {@value} 175 206.25 2 0 0.2 0.2 {name=R3}
T {m=@m} 185 223.75 2 0 0.2 0.2 {name=R3}
T {@spice_get_current} 165 170 1 1 0.2 0.2 {layer=17
name=R3}
T {@#0:pinnumber} 436.25 50 1 1 0.2 0.2 {layer=13
name=R2}
T {@#1:pinnumber} 393.75 50 1 1 0.2 0.2 {layer=13
name=R2}
T {@name} 415 48.75 2 0 0.2 0.2 {name=R2}
T {@value} 415 86.25 2 0 0.2 0.2 {name=R2}
T {m=@m} 415 103.75 2 0 0.2 0.2 {name=R2}
T {@spice_get_current} 405 50 1 1 0.2 0.2 {layer=17
name=R2}
T {@#0:pinnumber} 243.75 335 3 1 0.2 0.2 {layer=13
name=Co3}
T {@#1:pinnumber} 286.25 335 3 1 0.2 0.2 {layer=13
name=Co3}
T {@name} 265 301.25 0 0 0.2 0.2 {name=Co3}
T {@value} 265 343.75 0 0 0.2 0.2 {name=Co3}
T {@spice_get_current} 275 332.5 3 1 0.2 0.2 {layer=17
name=Co3}
T {@#0:pinnumber} 343.75 335 3 1 0.2 0.2 {layer=13
name=Co4}
T {@#1:pinnumber} 386.25 335 3 1 0.2 0.2 {layer=13
name=Co4}
T {@name} 365 301.25 0 0 0.2 0.2 {name=Co4}
T {@value} 365 343.75 0 0 0.2 0.2 {name=Co4}
T {@spice_get_current} 375 332.5 3 1 0.2 0.2 {layer=17
name=Co4}
T {@#0:pinnumber} 786.25 210 1 1 0.2 0.2 {layer=13
name=Rl}
T {@#1:pinnumber} 743.75 210 1 1 0.2 0.2 {layer=13
name=Rl}
T {@name} 765 208.75 2 0 0.2 0.2 {name=Rl}
T {@value} 765 246.25 2 0 0.2 0.2 {name=Rl}
T {m=@m} 765 263.75 2 0 0.2 0.2 {name=Rl}
T {@spice_get_current} 755 210 1 1 0.2 0.2 {layer=17
name=Rl}
T {@#0:pinnumber} 196.25 320 1 1 0.2 0.2 {layer=13
name=Rsrc}
T {@#1:pinnumber} 153.75 320 1 1 0.2 0.2 {layer=13
name=Rsrc}
T {@name} 175 318.75 2 0 0.2 0.2 {name=Rsrc}
T {@value} 175 356.25 2 0 0.2 0.2 {name=Rsrc}
T {m=@m} 175 373.75 2 0 0.2 0.2 {name=Rsrc}
T {@spice_get_current} 165 320 1 1 0.2 0.2 {layer=17
name=Rsrc}
T {Port 1} 40 310 0 0 0.3 0.3 {}
T {Port 2} 890 200 0 1 0.3 0.3 {}
N 470 60 470 80 {lab=#net1}
N 470 220 470 300 {lab=c}
N 580 220 600 220 {lab=#net2}
N 580 220 580 240 {lab=#net2}
N 560 220 580 220 {lab=#net2}
N 580 300 580 310 {lab=GND}
N 340 130 340 140 {lab=GND}
N 220 260 220 270 {lab=GND}
N 340 60 380 60 {lab=#net3}
N 470 60 530 60 {lab=#net1}
N 440 60 470 60 {lab=#net1}
N 120 180 140 180 {lab=#net4}
N 120 260 120 270 {lab=GND}
N 200 180 220 180 {lab=#net5}
N 300 180 400 180 {lab=b}
N 120 60 120 80 {lab=#net3}
N 120 140 120 180 {lab=#net4}
N 400 180 400 330 {lab=b}
N 400 330 430 330 {lab=b}
N 220 180 220 200 {lab=#net5}
N 220 180 240 180 {lab=#net5}
N 120 180 120 200 {lab=#net4}
N 320 330 340 330 {lab=#net6}
N 320 330 320 350 {lab=#net6}
N 300 330 320 330 {lab=#net6}
N 320 410 320 420 {lab=GND}
N 470 360 470 380 {lab=GND}
N 690 60 690 110 {lab=vcc}
N 690 60 850 60 {lab=vcc}
N 690 170 690 220 {lab=out}
N 660 220 690 220 {lab=out}
N 850 130 850 140 {lab=GND}
N 850 60 850 70 {lab=vcc}
N 810 290 810 320 {lab=GND}
N 590 60 690 60 {lab=vcc}
N 470 220 500 220 {lab=c}
N 470 140 470 220 {lab=c}
N 340 60 340 70 {lab=#net3}
N 120 60 340 60 {lab=#net3}
N 810 220 810 230 {lab=#net7}
N 120 400 120 430 {lab=GND}
N 120 330 140 330 {lab=#net8}
N 120 330 120 340 {lab=#net8}
N 790 220 810 220 {lab=#net7}
N 200 330 240 330 {lab=in}
N 690 220 730 220 {lab=out}
C {npn.sym} 450 330 0 0 {name=Q1
model=q2sc3358
device=2n2222
footprint=SOT23
area=1
m=1}
C {capa.sym} 530 220 3 0 {name=Co1
m=1
value=10p
footprint=1206
device="ceramic capacitor"
hide_texts=true
attach=Co1}
C {ind.sym} 470 110 0 0 {name=L3
m=1
value=10u
footprint=1206
device=inductor}
C {vsource.sym} 850 100 0 0 {name=Vcc value="dc=12" savecurrent=false}
C {lab_wire.sym} 430 330 0 0 {name=p1 sig_type=std_logic lab=b
}
C {lab_wire.sym} 470 220 0 0 {name=p2 sig_type=std_logic lab=c
}
C {ind.sym} 580 270 0 0 {name=L1
m=1
value=20n
footprint=1206
device=inductor}
C {gnd.sym} 580 310 0 0 {name=l4 lab=GND}
C {capa.sym} 630 220 3 0 {name=Co2
m=1
value=10p
footprint=1206
device="ceramic capacitor"
hide_texts=true
attach=Co2}
C {capa.sym} 340 100 0 0 {name=C2
m=1
value=10n
footprint=1206
device="ceramic capacitor"}
C {res.sym} 560 60 1 0 {name=R1
value=470
footprint=1206
device=resistor
m=1
hide_texts=true
attach=R1}
C {res.sym} 120 230 0 0 {name=Rp2
value=1.25k
footprint=1206
device=resistor
m=1}
C {res.sym} 120 110 0 0 {name=Rp1
value=3.75k
footprint=1206
device=resistor
m=1}
C {res.sym} 270 180 1 0 {name=R4
value=1k
footprint=1206
device=resistor
m=1
hide_texts=true
attach=R4}
C {gnd.sym} 340 140 0 0 {name=l5 lab=GND}
C {capa.sym} 220 230 0 0 {name=C4
m=1
value=10n
footprint=1206
device="ceramic capacitor"}
C {gnd.sym} 220 270 0 0 {name=l6 lab=GND}
C {res.sym} 170 180 1 0 {name=R3
value=1k
footprint=1206
device=resistor
m=1
hide_texts=true
attach=R3}
C {gnd.sym} 120 270 0 0 {name=l7 lab=GND}
C {res.sym} 410 60 1 0 {name=R2
value=2.2k
footprint=1206
device=resistor
m=1
hide_texts=true
attach=R2}
C {capa.sym} 270 330 3 0 {name=Co3
m=1
value=10p
footprint=1206
device="ceramic capacitor"
hide_texts=true
attach=Co3}
C {ind.sym} 320 380 0 0 {name=L8
m=1
value=20n
footprint=1206
device=inductor}
C {gnd.sym} 320 420 0 0 {name=l9 lab=GND}
C {capa.sym} 370 330 3 0 {name=Co4
m=1
value=10p
footprint=1206
device="ceramic capacitor"
hide_texts=true
attach=Co4}
C {gnd.sym} 470 380 0 0 {name=l10 lab=GND}
C {ind.sym} 690 140 0 0 {name=L11
m=1
value=10u
footprint=1206
device=inductor}
C {gnd.sym} 850 140 0 0 {name=l12 lab=GND}
C {res.sym} 760 220 1 0 {name=Rl
value=75
footprint=1206
device=resistor
m=1
hide_texts=true
attach=Rl}
C {vsource.sym} 810 260 0 0 {name=Vout value="dc=0 mag=0" savecurrent=false}
C {gnd.sym} 810 320 0 0 {name=l13 lab=GND}
C {lab_wire.sym} 690 220 0 0 {name=p5 sig_type=std_logic lab=out
}
C {res.sym} 170 330 1 0 {name=Rsrc
value=75
footprint=1206
device=resistor
m=1
hide_texts=true
attach=Rsrc}
C {vsource.sym} 120 370 0 1 {name=Vin value="dc=0 mag=1" savecurrent=false}
C {gnd.sym} 120 430 0 0 {name=l14 lab=GND}
C {lab_wire.sym} 240 330 0 0 {name=p6 sig_type=std_logic lab=in
}
C {lab_wire.sym} 690 60 0 1 {name=p7 sig_type=std_logic lab=vcc
}
C {simulator_commands_shown.sym} 970 110 0 0 {name=COMMANDS1
simulator=vacask
only_toplevel=false 
value="
load \\"spice/bjt.osdi\\"

model q2sc3358 sp_bjt ( type=1 
    bf=120 br=1 is=16f eg=1.11 cjc=0.5p cje=0.75p vaf=200
    tf=23p  tr=2n  mjc=.330  vjc=.75  mje=.33  vje=.75
    cjs=1p 
)

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

raw = rawread('op1.raw')
plot = raw.get()
print('Ic=', plot['L3:flow(br)'])

fig1 = plt.figure(figsize=(10,5), dpi=100)
fig1.suptitle('RF amplifier')
ax_dict = fig1.subplot_mosaic(\\"\\"\\"
AB
CB
\\"\\"\\", per_subplot_kw=\{'B': \{'projection': 'polar'\}\})

raw = rawread('ac1.raw')
plot = raw.get()

ax_dict['A'].set_ylabel('Gain [dB]')
ax_dict['A'].semilogx(np.real(plot['frequency'])/1e6, 20*np.log10(np.abs((plot['out']/plot['in']))))
ax_dict['A'].set_ylim(0, 40)

#ax_dict['B'].loglog(np.real(plot['frequency'])/1e6, np.abs(plot['in']/plot['vin:flow(br)']))

raw = rawread('acsp1.raw')
plot = raw.get()
print(plot.names)

s11 = plot['s(1,1)']
s12 = plot['s(1,2)']
s21 = plot['s(2,1)']
s22 = plot['s(2,2)']

ax_dict['C'].set_ylabel('Sij [dB]')
ax_dict['C'].set_xlabel('f [MHz]')
ax_dict['C'].semilogx(np.real(plot['frequency'])/1e6, 20*np.log10(np.abs(s11)), 'r-', label='s11')
ax_dict['C'].semilogx(np.real(plot['frequency'])/1e6, 20*np.log10(np.abs(s21)), 'b-', label='s21')
ax_dict['C'].semilogx(np.real(plot['frequency'])/1e6, 20*np.log10(np.abs(s12)), 'r--', label='s12')
ax_dict['C'].semilogx(np.real(plot['frequency'])/1e6, 20*np.log10(np.abs(s22)), 'b--', label='s22')
ax_dict['C'].legend(loc='lower left', framealpha=1)
ax_dict['C'].set_ylim(-70, 30)

ax_dict['B'].plot(np.angle(s11), 10*np.abs(s11), 'r-', label='10x s11')
ax_dict['B'].plot(np.angle(s21), np.abs(s21), 'b-', label='s21')
ax_dict['B'].plot(np.angle(s12), 100*np.abs(s12), 'r--', label='100x s12')
ax_dict['B'].plot(np.angle(s22), 10*np.abs(s22), 'b--', label='10x s22')
ax_dict['B'].legend(loc='upper left', framealpha=1)

fig1.tight_layout()

plt.show()
>>>FILE
"}
C {command_block.sym} 60 550 0 0 {name=CMD
only_toplevel=false
}
C {acsp.sym} 270 550 0 0 {name=acsp1
only_toplevel=false 
order="3"
sweep=""
ports="[\\"Vin\\",\\"Rsrc\\",\\"Vout\\",\\"Rl\\"]"
from=100M
to=1G
step=""
mode="\\"dec\\""
points="1000"
values=""
nodeset=""
store=""
write=""
writeop=""
}
C {postproc.sym} 270 800 0 0 {name=postproc1
only_toplevel=false 
order="4"
tool="PYTHON"
file="\\"runme.py\\""
}
C {op.sym} 60 680 0 0 {name=op1
only_toplevel=false 
order="1"
sweep=""
nodeset=""
store=""
write=""
}
C {ac.sym} 60 800 0 0 {name=ac1
only_toplevel=false 
order="2"
sweep=""
from=100M
to=1G
step=""
mode="\\"dec\\""
points="1000"
values=""
nodeset=""
store=""
write=""
writeop=""
}
