Update processing script.

This commit is contained in:
Danila Fedorin 2021-01-18 13:56:27 -08:00
parent b32dfd2a36
commit 1ca79fc52b

View File

@ -102,18 +102,34 @@ def find_onoff(ident, script, model, mos, l):
vds = l.get_data('vds')
current_lo = l.get_data('I(vds)', 0)
current_hi = l.get_data('I(vds)', l.case_count - 1)
print(ident, current_lo[-5], current_hi[-5])
if mos == "nmos":
print(ident, -current_lo[-1] * 1000, -current_hi[-1] * 1000, current_hi[-1]/current_lo[-1])
if mos == "pmos":
print(ident, current_lo[0] * 1000, current_hi[0] * 1000, current_lo[0]/current_hi[0])
def find_gm(ident, script, model, mos, l):
vds = l.get_data('vds')
gms = []
for i in range(l.case_count):
if i == 0: continue
max_diff = max(
[ abs(curr - prev) for (curr, prev) in
zip(l.get_data('I(vds)', i), l.get_data('I(vds)', i-1)) ])
gms.append(max_diff/(simulations[model][0]/12))
print(ident, max(gms) * 10000)
if mos == "nmos":
vgs1 = l.get_data('I(vds)', l.case_count - 2)
vgs2 = l.get_data('I(vds)', l.case_count - 1)
gm = (vgs2[-1]-vgs1[-1])/(simulations[model][0]/12)
print(ident, -gm * 1000, "mA/V")
vds = l.get_data('vds', l.case_count - 1)
ids = l.get_data('I(vds)', l.case_count - 1)
ro = (vds[-5] - vds[-1])/(ids[-5] - ids[-1])
print(ident, -ro, "O")
print(ident, gm * ro)
if mos == "pmos":
vgs1 = l.get_data('I(vds)', 0)
vgs2 = l.get_data('I(vds)', 1)
gm = (vgs2[0]-vgs1[0])/(simulations[model][0]/12)
print(ident, -gm * 1000, "mA/V")
vds = l.get_data('vds', 0)
ids = l.get_data('I(vds)', 0)
ro = (vds[50] - vds[0])/(ids[50] - ids[0])
print(ident, -ro, "O")
print(ident, gm * ro)
def render_current(ident, script, model, mos, l):
vds = l.get_data('vds')
@ -123,8 +139,8 @@ def render_current(ident, script, model, mos, l):
plt.savefig(ident + "_current.png", dpi=192)
plt.close()
def run_sim(script, model, mos, callback):
scriptname = "t_{}_{}".format(model, mos)
def run_sim(script, model, mos, callback, file_type = "dc"):
scriptname = "{}_{}_{}".format(file_type, model, mos)
with open(scriptname + ".cir", "w") as f:
f.write(simulations[model][1].format(simulations[model][0]))
if mos is not None: f.write(moss[mos])
@ -139,9 +155,16 @@ def run_sim(script, model, mos, callback):
callback(scriptname, script, model, mos, l)
print(" --- gm, ro --- ")
for mos in moss.keys():
for node in simulations.keys():
run_sim(script_dc, node, mos, find_gm)
print(" --- onoff --- ")
for mos in moss.keys():
for node in simulations.keys():
run_sim(script_dc, node, mos, find_onoff)
print(" --- period --- ")
for node in simulations.keys():
run_sim(script_ring, node, None, find_period)
run_sim(script_ring, node, None, find_period, "t")