Skip to content

Commit

Permalink
convert to python 3 devsim module
Browse files Browse the repository at this point in the history
  • Loading branch information
tcaduser committed Nov 2, 2018
1 parent b04230d commit 3815a45
Show file tree
Hide file tree
Showing 24 changed files with 1,607 additions and 1,610 deletions.
10 changes: 5 additions & 5 deletions simdir/README
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# create the background mesh
# use the background mesh
gmsh -2 bjt.geo
devsim bjt_refine.py
python bjt_refine.py
gmsh -2 bjt.geo -bgm ./bjt_bgmesh.pos
devsim bjt_refine.py
python bjt_refine.py
gmsh -2 bjt.geo -bgm ./bjt_bgmesh.pos
devsim bjt_refine.py
python bjt_refine.py
gmsh -2 bjt.geo -bgm ./bjt_bgmesh.pos
devsim bjt_refine.py
python bjt_refine.py
gmsh -2 bjt.geo -bgm ./bjt_bgmesh.pos
devsim bjt_refine.py
python bjt_refine.py

#visualize
visit bjt_refine.tec
Expand Down
2,848 changes: 1,424 additions & 1,424 deletions simdir/bjt_bgmesh.pos

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion simdir/bjt_circuit5.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import sys
from ds import *
from devsim import *
Vc=float(sys.argv[1])
fmin=float(sys.argv[2])
fmax=float(sys.argv[3])
Expand Down
12 changes: 6 additions & 6 deletions simdir/bjt_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from ds import *
from devsim import *
from physics.new_physics import *
import bjt_params
import netdoping

def make_bias(contact):
def mycall():
print "BIAS %s %1.15g" % (contact, get_circuit_node_value(solution="dcop", node=GetContactBiasName(contact)))
print("BIAS %s %1.15g" % (contact, get_circuit_node_value(solution="dcop", node=GetContactBiasName(contact))))
return mycall

def make_sweep(contact_names, bias_names):
Expand All @@ -30,13 +30,13 @@ def mycall():
v.append("%1.15g" % get_circuit_node_value(solution="dcop", node=GetContactBiasName(c)))
for b in bias_names:
v.append("%1.15g" % -get_circuit_node_value(solution="dcop", node=b+".I"))
print "CURVE: " + " ".join(v)
print("CURVE: " + " ".join(v))
h = []
for c in contact_names:
h.append("V(%s)" % c)
for c in contact_names:
h.append("I(%s)" % c)
print "HEADER: " + " ".join(h)
print("HEADER: " + " ".join(h))
return mycall

def make_ac_callback(contact_names, bias_names, minf, maxf, ppd):
Expand All @@ -59,7 +59,7 @@ def make_ac_callback(contact_names, bias_names, minf, maxf, ppd):
for c in contact_names:
h.append("IR(%s)" % c)
h.append("II(%s)" % c)
print "ACHEADER: " + " ".join(h)
print("ACHEADER: " + " ".join(h))
def ac_callback():
# solve a few extra times for better ac sensitivity
solve(type="dc", absolute_error=1e10, relative_error=1e-2, maximum_iterations=40)
Expand All @@ -77,7 +77,7 @@ def ac_callback():
for b in bias_names:
v.append("%1.15g" % -get_circuit_node_value(solution="ssac_real", node=b+".I"))
v.append("%1.15g" % -get_circuit_node_value(solution="ssac_imag", node=b+".I"))
print "AC: " + " ".join(v)
print("AC: " + " ".join(v))
return ac_callback

def run():
Expand Down
2 changes: 1 addition & 1 deletion simdir/bjt_dd.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from ds import *
from devsim import *

device="bjt"
region="bjt"
Expand Down
22 changes: 11 additions & 11 deletions simdir/bjt_doping.tec

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion simdir/bjt_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from ds import *
from devsim import *

def run(device, region):
pass
Expand Down
2 changes: 1 addition & 1 deletion simdir/bjt_refine.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from ds import *
from devsim import *

device="bjt"
region="bjt"
Expand Down
165 changes: 81 additions & 84 deletions simdir/bjt_refine.tec

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion simdir/bjt_restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from ds import *
from devsim import *

device="bjt"
region="bjt"
Expand Down
2 changes: 1 addition & 1 deletion simdir/diode_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from ds import *
from devsim import *
from physics.new_physics import *
#####
# dio1
Expand Down
2 changes: 1 addition & 1 deletion simdir/initial_guess.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from ds import *
from devsim import *
from physics.new_physics import *

def run(device, region):
Expand Down
2 changes: 1 addition & 1 deletion simdir/netdoping.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from ds import *
from devsim import *

def set_params(device, region):
params = {
Expand Down
18 changes: 9 additions & 9 deletions simdir/physics/model_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from ds import *
from devsim import *
debug = False
def CreateSolution(device, region, name):
'''
Expand All @@ -28,7 +28,7 @@ def CreateNodeModel(device, region, model, expression):
'''
result=node_model(device=device, region=region, name=model, equation=expression)
if debug:
print("NODEMODEL {d} {r} {m} \"{re}\"".format(d=device, r=region, m=model, re=result))
print(("NODEMODEL {d} {r} {m} \"{re}\"".format(d=device, r=region, m=model, re=result)))

def CreateNodeModelDerivative(device, region, model, expression, *vars):
'''
Expand All @@ -47,7 +47,7 @@ def CreateContactNodeModel(device, contact, model, expression):
'''
result=contact_node_model(device=device, contact=contact, name=model, equation=expression)
if debug:
print("CONTACTNODEMODEL {d} {c} {m} \"{re}\"".format(d=device, c=contact, m=model, re=result))
print(("CONTACTNODEMODEL {d} {c} {m} \"{re}\"".format(d=device, c=contact, m=model, re=result)))


def CreateContactNodeModelDerivative(device, contact, model, expression, variable):
Expand All @@ -65,7 +65,7 @@ def CreateEdgeModel (device, region, model, expression):
'''
result=edge_model(device=device, region=region, name=model, equation=expression)
if debug:
print "EDGEMODEL {d} {r} {m} \"{re}\"".format(d=device, r=region, m=model, re=result);
print("EDGEMODEL {d} {r} {m} \"{re}\"".format(d=device, r=region, m=model, re=result));

def CreateEdgeModelDerivatives(device, region, model, expression, variable):
'''
Expand All @@ -86,7 +86,7 @@ def CreateContactEdgeModel(device, contact, model, expression):
'''
result=contact_edge_model(device=device, contact=contact, name=model, equation=expression)
if debug:
print("CONTACTEDGEMODEL {d} {c} {m} \"{re}\"".format(d=device, c=contact, m=model, re=result))
print(("CONTACTEDGEMODEL {d} {c} {m} \"{re}\"".format(d=device, c=contact, m=model, re=result)))

def CreateContactEdgeModelDerivative(device, contact, model, expression, variable):
'''
Expand All @@ -101,7 +101,7 @@ def CreateInterfaceModel(device, interface, model, expression):
'''
result=interface_model(device=device, interface=interface, name=model, equation=expression)
if debug:
print("INTERFACEMODEL {d} {i} {m} \"{re}\"".format(d=device, i=interface, m=model, re=result))
print(("INTERFACEMODEL {d} {i} {m} \"{re}\"".format(d=device, i=interface, m=model, re=result)))

#def CreateInterfaceModelDerivative(device, interface, model, expression, variable):
# '''
Expand Down Expand Up @@ -138,19 +138,19 @@ def EnsureEdgeFromNodeModelExists(device, region, nodemodel):
Checks if the edge models exists
'''
if not InNodeModelList(device, region, nodemodel):
raise("{} must exist" % (nodemodel))
raise "{} must exist"

emlist = get_edge_model_list(device=device, region=region)
emtest = ("{0}@n0".format(nodemodel) and "{0}@n1".format(nodemodel))
if not emtest:
if debug:
print "INFO: Creating ${0}@n0 and ${0}@n1".format(nodemodel)
print("INFO: Creating ${0}@n0 and ${0}@n1".format(nodemodel))
edge_from_node_model(device=device, region=region, node_model=nodemodel)

def CreateElementModel2d(device, region, model, expression):
result=element_model(device=device, region=region, name=model, equation=expression)
if debug:
print("ELEMENTMODEL {d} {r} {m} \"{re}\"".format(d=device, r=region, m=model, re=result))
print(("ELEMENTMODEL {d} {r} {m} \"{re}\"".format(d=device, r=region, m=model, re=result)))


def CreateElementModelDerivative2d(device, region, model_name, expression, *args):
Expand Down
4 changes: 2 additions & 2 deletions simdir/physics/new_physics.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from ds import *
from model_create import *
from devsim import *
from .model_create import *

def SetUniversalParameters(device, region):
universal = {
Expand Down
78 changes: 39 additions & 39 deletions simdir/physics/ramp2.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# limitations under the License.

import sys
import ds
from new_physics import *
import devsim
from .new_physics import *

### modify to grow and shrink size
def rampvoltage(device, Vsource, begin_bias, end_bias, init_step_size, min_step, max_iter, rel_error, abs_error, callback):
Expand All @@ -32,7 +32,7 @@ def rampvoltage(device, Vsource, begin_bias, end_bias, init_step_size, min_step,
last_bias=start_bias
step_size=init_step_size
while(abs(last_bias - end_bias) > min_step):
print("last end %e %e") % (last_bias, end_bias)
print(("last end %e %e") % (last_bias, end_bias))
next_bias=last_bias + step_sign * step_size
if next_bias < end_bias:
next_step_sign=1
Expand All @@ -41,45 +41,45 @@ def rampvoltage(device, Vsource, begin_bias, end_bias, init_step_size, min_step,

if next_step_sign != step_sign:
next_bias=end_bias
print "setting to last bias %e" % (end_bias)
print "setting next bias %e" % (next_bias)
print("setting to last bias %e" % (end_bias))
print("setting next bias %e" % (next_bias))

ds.circuit_alter(name=Vsource, value=next_bias)
devsim.circuit_alter(name=Vsource, value=next_bias)
try:
ds.solve(type="dc", absolute_error=abs_error, relative_error=rel_error, maximum_iterations=max_iter)
except ds.error as msg:
if msg[0].find("Convergence failure") != 0:
devsim.solve(type="dc", absolute_error=abs_error, relative_error=rel_error, maximum_iterations=max_iter)
except devsim.error as msg:
if str(msg).find("Convergence failure") != 0:
raise
ds.circuit_alter(name=Vsource, value=last_bias)
devsim.circuit_alter(name=Vsource, value=last_bias)
step_size *= 0.5
print "setting new step size %e" % (step_size)
print("setting new step size %e" % (step_size))
if step_size < min_step:
raise NameError("Min step size too small")
raise RuntimeError("Min step size too small")
num_successes = 0
continue
num_successes += 1
if (num_successes > 5) and (step_size < init_step_size):
step_size *= 2
if step_size > init_step_size:
step_size = init_step_size
print "setting new step size %e" % (step_size)
print("setting new step size %e" % (step_size))
num_successes = 0
print "Succeeded"
print("Succeeded")
last_bias=next_bias
callback()

def rampbias(device, contact, end_bias, step_size, min_step, max_iter, rel_error, abs_error, callback):
'''
Ramps bias with assignable callback function
'''
start_bias=ds.get_parameter(device=device, name=GetContactBiasName(contact))
start_bias=devsim.get_parameter(device=device, name=GetContactBiasName(contact))
if (start_bias < end_bias):
step_sign=1
else:
step_sign=-1
last_bias=start_bias
while(abs(last_bias - end_bias) > min_step):
print("last end %e %e") % (last_bias, end_bias)
print(("last end %e %e") % (last_bias, end_bias))
next_bias=last_bias + step_sign * step_size
if next_bias < end_bias:
next_step_sign=1
Expand All @@ -88,36 +88,36 @@ def rampbias(device, contact, end_bias, step_size, min_step, max_iter, rel_error

if next_step_sign != step_sign:
next_bias=end_bias
print "setting to last bias %e" % (end_bias)
print "setting next bias %e" % (next_bias)
ds.set_parameter(device=device, name=GetContactBiasName(contact), value=next_bias)
print("setting to last bias %e" % (end_bias))
print("setting next bias %e" % (next_bias))
devsim.set_parameter(device=device, name=GetContactBiasName(contact), value=next_bias)
try:
ds.solve(type="dc", absolute_error=abs_error, relative_error=rel_error, maximum_iterations=max_iter)
except ds.error as msg:
devsim.solve(type="dc", absolute_error=abs_error, relative_error=rel_error, maximum_iterations=max_iter)
except devsim.error as msg:
if msg[0].find("Convergence failure") != 0:
raise
ds.set_parameter(device=device, name=GetContactBiasName(contact), value=last_bias)
devsim.set_parameter(device=device, name=GetContactBiasName(contact), value=last_bias)
step_size *= 0.5
print "setting new step size %e" % (step_size)
print("setting new step size %e" % (step_size))
if step_size < min_step:
raise "Min step size too small"
raise RuntimeError("Min step size too small")
continue
print "Succeeded"
print("Succeeded")
last_bias=next_bias
callback()

def rampbias(device, contact, end_bias, step_size, min_step, max_iter, rel_error, abs_error, callback):
'''
Ramps bias with assignable callback function
'''
start_bias=ds.get_parameter(device=device, name=GetContactBiasName(contact))
start_bias=devsim.get_parameter(device=device, name=GetContactBiasName(contact))
if (start_bias < end_bias):
step_sign=1
else:
step_sign=-1
last_bias=start_bias
while(abs(last_bias - end_bias) > min_step):
print("last end %e %e") % (last_bias, end_bias)
print(("last end %e %e") % (last_bias, end_bias))
next_bias=last_bias + step_sign * step_size
if next_bias < end_bias:
next_step_sign=1
Expand All @@ -126,21 +126,21 @@ def rampbias(device, contact, end_bias, step_size, min_step, max_iter, rel_error

if next_step_sign != step_sign:
next_bias=end_bias
print "setting to last bias %e" % (end_bias)
print "setting next bias %e" % (next_bias)
ds.set_parameter(device=device, name=GetContactBiasName(contact), value=next_bias)
print("setting to last bias %e" % (end_bias))
print("setting next bias %e" % (next_bias))
devsim.set_parameter(device=device, name=GetContactBiasName(contact), value=next_bias)
try:
ds.solve(type="dc", absolute_error=abs_error, relative_error=rel_error, maximum_iterations=max_iter)
except ds.error as msg:
if msg[0].find("Convergence failure") != 0:
devsim.solve(type="dc", absolute_error=abs_error, relative_error=rel_error, maximum_iterations=max_iter)
except devsim.error as msg:
if str(msg).find("Convergence failure") != 0:
raise
ds.set_parameter(device=device, name=GetContactBiasName(contact), value=last_bias)
devsim.set_parameter(device=device, name=GetContactBiasName(contact), value=last_bias)
step_size *= 0.5
print "setting new step size %e" % (step_size)
print("setting new step size %e" % (step_size))
if step_size < min_step:
raise "Min step size too small"
raise RuntimeError("Min step size too small")
continue
print "Succeeded"
print("Succeeded")
last_bias=next_bias
callback(device)

Expand All @@ -159,6 +159,6 @@ def PrintCurrents(device, contact):
electron_current= get_contact_current(device=device, contact=contact, equation=ece_name)
hole_current = get_contact_current(device=device, contact=contact, equation=hce_name)
total_current = electron_current + hole_current
voltage = ds.get_parameter(device=device, name=GetContactBiasName(contact))
print "{0}\t{1}\t{2}\t{3}\t{4}".format(contact, voltage, electron_current, hole_current, total_current)
voltage = devsim.get_parameter(device=device, name=GetContactBiasName(contact))
print("{0}\t{1}\t{2}\t{3}\t{4}".format(contact, voltage, electron_current, hole_current, total_current))

Loading

0 comments on commit 3815a45

Please sign in to comment.