Example #1
0
    def __init__(self, instanceName):
        """
        The name of the element is formed by combining the given
        instanceName and the device type. 

        Example: diode:d1
        """
        # Call base class constructors
        GraphNode.__init__(self, self.devType + ':' + instanceName)
        # Note: paramDict must be defined by the derived class
        ParamSet.__init__(self, self.paramDict)
        # Default is not to have a separate model
        self.dotModel = False
Example #2
0
    def __init__(self, instanceName):
        """
        The name of the element is formed by combining the given
        instanceName and the device type. 

        Example: diode:d1
        """
        # Call base class constructors
        GraphNode.__init__(self, self.devType + ':' + instanceName)
        # Note: paramDict must be defined by the derived class
        ParamSet.__init__(self, self.paramDict)
        # Default is not to have a separate model
        self.dotModel = False
Example #3
0
 def __str__(self):
     """convert to string"""
     desc = 'Element: ' + GraphNode.__str__(self)
     desc += '\nDevice type: ' + self.devType + '\n' 
     if self.dotModel:
         desc += 'Model: {0}\n'.format(self.dotModel.name)
     desc += 'Overridden parameters: ' + ParamSet.netlist_string(self)
     return(desc)
Example #4
0
 def __str__(self):
     """convert to string"""
     desc = 'Element: ' + GraphNode.__str__(self)
     desc += '\nDevice type: ' + self.devType + '\n' 
     if self.dotModel:
         desc += 'Model: {0}\n'.format(self.dotModel.name)
     desc += 'Overridden parameters: ' + ParamSet.netlist_string(self)
     return(desc)
Example #5
0
    def set_attributes(self):
        """
        Set parameters as attributes. 

        Priority is as follows: first manually set parameters, then
        manually set parameters in model (if any) and finally default
        values
        """
        # Ambient temperature (temp) initially set to global
        # temperature, but may be overriden by the model or the
        # element line attributes
        self.temp = glVar.temp
        # Set overrides first
        if self.dotModel:
            ParamSet.set_attributes(self, useDefaults = False)
            # Get other attributes from model
            self.dotModel.set_missing_attributes(self)
        else:
            ParamSet.set_attributes(self, useDefaults = True)
Example #6
0
    def set_attributes(self):
        """
        Set parameters as attributes. 

        Priority is as follows: first manually set parameters, then
        manually set parameters in model (if any) and finally default
        values
        """
        # Ambient temperature (temp) initially set to global
        # temperature, but may be overriden by the model or the
        # element line attributes
        self.temp = glVar.temp
        # Set overrides first
        if self.dotModel:
            ParamSet.set_attributes(self, useDefaults = False)
            # Get other attributes from model
            self.dotModel.set_missing_attributes(self)
        else:
            ParamSet.set_attributes(self, useDefaults = True)
Example #7
0
 def print_vars(self):
     """
     Nicely print parameter list and OP (if any) with values and units
     """
     print('Parameter values:\n')
     print(ParamSet.__str__(self))
     if hasattr(self, 'OP'):
         print('Operating point information:\n')
         print(' Variable  |  Value ')
         print('-------------------------')
         print(self.format_OP())
Example #8
0
 def is_set(self, paramName):
     """
     Returns True if paramName is valid and manually set
     """
     # check if parameter in model first
     if self.dotModel:
         answer = self.dotModel.is_set(paramName)
     else:
         answer = False
     # now check in element
     if not answer:
         answer = ParamSet.is_set(self, paramName)
     return answer
Example #9
0
 def is_set(self, paramName):
     """
     Returns True if paramName is valid and manually set
     """
     # check if parameter in model first
     if self.dotModel:
         answer = self.dotModel.is_set(paramName)
     else:
         answer = False
     # now check in element
     if not answer:
         answer = ParamSet.is_set(self, paramName)
     return answer
Example #10
0
 def netlist_string(self):
     """
     Output netlist-formatted string in netlist format
     """
     desc = '{0} '.format(self.instanceName)
     # Add terminals
     for i, term in enumerate(self.connection):
         # Do not include internal terminals. The following works
         # even when numTerms is not set.
         if issubclass(type(term), InternalTerminal):
             break
         desc += term.instanceName + ' '
     # Model (if any)
     if self.dotModel:
         desc += 'model = {0} '.format(self.dotModel.name)
     # Parameters
     desc += ParamSet.netlist_string(self)
     return(desc)
Example #11
0
 def netlist_string(self):
     """
     Output netlist-formatted string in netlist format
     """
     desc = '{0} '.format(self.instanceName)
     # Add terminals
     for i, term in enumerate(self.connection):
         # Do not include internal terminals. The following works
         # even when numTerms is not set.
         if issubclass(type(term), InternalTerminal):
             break
         desc += term.instanceName + ' '
     # Model (if any)
     if self.dotModel:
         desc += 'model = {0} '.format(self.dotModel.name)
     # Parameters
     desc += ParamSet.netlist_string(self)
     return(desc)
Example #12
0
constDict = dict(
    k = ('Boltzmann constant', 'J K^{-1}', float, 1.3806488e-23),
    q = ('Elementary charge', 'C', float, 1.602176565e-19),
    epsilon0 = ('Permittivity of free space', 'F m^{-1}', 
     float, 8.854187817e-12),
    mu0 = ('Permeability of free space', 'H m^{-1}', float,
     np.pi*4e-7),
    c0 = ('Speed of light in free space', 'm s^{-1}', float, 2.99792458e8),
    T0 = ('Zero degree Celsius temperature', 'K', float, 273.15),
    epSi = ('Permitivity of silicon', '', float, 104.5e-12),
    epOx = ('Permitivity of silicon oxide', '', float, 34.5e-12),
    Np2dB = ('Neper to dB conversion constant', 'dB/Np', 
             float, 8.6858896380650368)
    )

const = ParamSet(constDict)
const.set_attributes()

globDict = dict(
    temp = ('Ambient temperature', 'C', float, 27.),
    abstol = ('Absolute tolerance for nodal variables', 'nodal unit', 
              float, 1e-7),
    reltol = ('Relative tolerance for nodal variables', '', float, 1e-4),
    maxiter = ('Maximum number of Newton iterations', '', int, 20),
    maxdelta = ('Maximum allowed change in one Newton iteration', 
                'nodal unit', float, 20.),
    errfunc = ("Enable additional test for error function in Newton's method", 
               'bool', bool, False),
    sparse = ("Use sparse matrices in analyses if possible", 'bool', 
              bool, True),
    gyr = ('Default gain in internal gyrators', 'S', float, 1e-3)
Example #13
0
 def __init__(self):
     # Just init the base class
     ParamSet.__init__(self, self.paramDict)
Example #14
0
 def print_vars(self):
     """
     Nicely print parameter list and OP (if any) with values and units
     """
     print('Parameter values:\n')
     print(ParamSet.__str__(self))
Example #15
0
 def print_vars(self):
     """
     Nicely print parameter list and OP (if any) with values and units
     """
     print('Parameter values:\n')
     print(ParamSet.__str__(self))