1313# limitations under the License.
1414
1515import sys
16- sys .path .append ('../../python_packages' )
17- from devsim import *
18- import devsim
16+ import devsim as ds
1917from .simple_physics import *
2018
2119def rampbias (device , contact , end_bias , step_size , min_step , max_iter , rel_error , abs_error , callback ):
2220 '''
2321 Ramps bias with assignable callback function
2422 '''
25- start_bias = get_parameter (device = device , name = GetContactBiasName (contact ))
23+ start_bias = ds . get_parameter (device = device , name = GetContactBiasName (contact ))
2624 if (start_bias < end_bias ):
2725 step_sign = 1
2826 else :
2927 step_sign = - 1
28+ step_size = abs (step_size )
29+
3030 last_bias = start_bias
3131 while (abs (last_bias - end_bias ) > min_step ):
32- print (("last end %e %e" ) % (last_bias , end_bias ))
32+ print (("%s last end %e %e" ) % (contact , last_bias , end_bias ))
3333 next_bias = last_bias + step_sign * step_size
3434 if next_bias < end_bias :
3535 next_step_sign = 1
@@ -40,17 +40,17 @@ def rampbias(device, contact, end_bias, step_size, min_step, max_iter, rel_error
4040 next_bias = end_bias
4141 print ("setting to last bias %e" % (end_bias ))
4242 print ("setting next bias %e" % (next_bias ))
43- set_parameter (device = device , name = GetContactBiasName (contact ), value = next_bias )
43+ ds . set_parameter (device = device , name = GetContactBiasName (contact ), value = next_bias )
4444 try :
45- solve (type = "dc" , absolute_error = abs_error , relative_error = rel_error , maximum_iterations = max_iter )
46- except devsim .error as msg :
47- if msg [ 0 ] .find ("Convergence failure" ) != 0 :
45+ ds . solve (type = "dc" , absolute_error = abs_error , relative_error = rel_error , maximum_iterations = max_iter )
46+ except ds .error as msg :
47+ if str ( msg ) .find ("Convergence failure" ) != 0 :
4848 raise
49- set_parameter (device = device , name = GetContactBiasName (contact ), value = last_bias )
49+ ds . set_parameter (device = device , name = GetContactBiasName (contact ), value = last_bias )
5050 step_size *= 0.5
5151 print ("setting new step size %e" % (step_size ))
5252 if step_size < min_step :
53- raise "Min step size too small"
53+ raise RuntimeError ( "Minimum step size too small")
5454 continue
5555 print ("Succeeded" )
5656 last_bias = next_bias
@@ -60,6 +60,6 @@ def printAllCurrents(device):
6060 '''
6161 Prints all contact currents on device
6262 '''
63- for c in get_contact_list (device = device ):
63+ for c in ds . get_contact_list (device = device ):
6464 PrintCurrents (device , c )
6565
0 commit comments