def get_ds_status(): devices = ds.get_device_list() for device in devices: print("Device: " + device) regions = ds.get_region_list(device=device) for region in regions: print("\tRegion :" + region) params = ds.get_parameter_list(device=device, region=region) for param in params: val = ds.get_parameter(device=device, region=region, name=param) print(f"\t\t{param} = {val}") n_models = ds.get_node_model_list(device=device, region=region) for node_model in n_models: nmvals = ds.get_node_model_values(device=device, region=region, name=node_model) print(f"\t\t Node Model '{node_model}' = {nmvals!s}") e_models = ds.get_edge_model_list(device=device, region=region) for edge_model in e_models: emvals = ds.get_edge_model_values(device=device, region=region, name=edge_model) print(f"\t\t Edge Model '{edge_model}' = {emvals!s}") contacts = ds.get_contact_list(device=device) for contact in contacts: print("\tContact : " + contact) c_eqs = ds.get_contact_equation_list(device=device, contact=contact) for ceq in c_eqs: print("\t\tContact Equation : " + ceq)
def PrintCurrents(device, contact): ''' print out contact currents ''' contact_bias_name = GetContactBiasName(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)
def print_currents(self): for c in self.mesh.contacts: e_current = get_contact_current( device=device, contact=c, equation='ElectronContinuityEquation') h_current = get_contact_current(device=device, contact=c, equation='HoleContinuityEquation') total_current = e_current + h_current voltage = get_parameter(device=device, name=self._contact_bias_name(contact)) log.info("{0}\t{1}\t{2}\t{3}\t{4}".format(contact, voltage, e_current, h_current, total_current))
def get_ds_status(short=True): """ Prints the status of the current devsim setup and all variables, solutions, node models and edge models :return: """ for device in ds.get_device_list(): print("Device: " + device) for region in ds.get_region_list(device=device): print("\tRegion :" + region) params = ds.get_parameter_list(device=device, region=region) for param in params: val = ds.get_parameter(device=device, region=region, name=param) print(f"\t\t{param} = {val}") for node_model in ds.get_node_model_list(device=device, region=region): nmvals = ds.get_node_model_values(device=device, region=region, name=node_model) nmstr = ','.join([f'{val:.3g}' for val in nmvals]) print(f"\t\tNode Model '{node_model}' = {nmstr!s}") e_models = ds.get_edge_model_list(device=device, region=region) for edge_model in e_models: emvals = ds.get_edge_model_values(device=device, region=region, name=edge_model) emstr = ','.join([f'{val:.3g}' for val in emvals]) print(f"\t\tEdge Model '{edge_model}' = {emstr}") for interface in ds.get_interface_list(device=device): print("\tInterface: " + interface) for imodel in ds.get_interface_model_list(device=device, interface=interface): intstr = ','.join([ f'{val:.3g}' for val in ds.get_interface_model_values( device=device, interface=interface, name=imodel) ]) print(f"\t\tInterface Model: '{imodel}' = {intstr}") for ieq in ds.get_interface_equation_list(device=device, interface=interface): # comm = ds.get_interface_equation_command(device=device, interface=interface, name=ieq) print(f"\t\tInterface Equation: {ieq}") contacts = ds.get_contact_list(device=device) for contact in contacts: print("\tContact : " + contact) c_eqs = ds.get_contact_equation_list(device=device, contact=contact) for ceq in c_eqs: print("\t\tContact Equation : " + ceq)
def get_voltage_current(device=None, contact=None, ece_name="ElectronContinuityEquation", hce_name="HoleContinuityEquation"): ''' Return voltage and current for the device ''' if device is None: device = ds.get_device_list()[0] logger.warning(f"No device specified! Assuming '{device}'") if contact is None: contact = ds.get_contact_list(device)[0] electron_current = ds.get_contact_current(device=device, contact=contact, equation=ece_name) hole_current = ds.get_contact_current(device=device, contact=contact, equation=hce_name) total_current = electron_current + hole_current voltage = ds.get_parameter(device=device, name=f"{contact}_bias") return voltage, total_current
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)) 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)) next_bias = last_bias + step_sign * step_size if next_bias < end_bias: next_step_sign = 1 else: next_step_sign = -1 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) 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: raise ds.set_parameter(device=device, name=GetContactBiasName(contact), value=last_bias) step_size *= 0.5 print("setting new step size %e" % (step_size)) if step_size < min_step: raise "Min step size too small" continue 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)) 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) next_bias=last_bias + step_sign * step_size if next_bias < end_bias: next_step_sign=1 else: next_step_sign=-1 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) 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: raise ds.set_parameter(device=device, name=GetContactBiasName(contact), value=last_bias) step_size *= 0.5 print "setting new step size %e" % (step_size) if step_size < min_step: raise "Min step size too small" continue print "Succeeded" last_bias=next_bias callback()
def top_bias(self): return get_parameter(device=self.name, name=f"{self.contacts[0]}_bias")