Exemple #1
0
    def __init__(self, *args, **kvargs):
        if 'toolkit' in kvargs:
            self.toolkit = kvargs['toolkit']
            del kvargs['toolkit']
        else:
            self.toolkit = default_toolkit

        self.nodenames = {}

        ## Add terminal nodes
        self.add_terminals(self.terminals)

        ## Set temporary terminal mapping information for use by instantiation
        ## method in higher hierarchy
        self.terminalhook = dict(zip(self.terminals, args))

        ## Create instance parameters
        self.iparv = ParameterDict(*self.instparams)
        self.ipar = ParameterDict(*self.instparams)

        ## Subscribe to changes on ipar
        self.ipar.attach(self, updatemethod='_ipar_changed')

        ## set instance parameters from arguments
        self.ipar.set(**kvargs)

        ## Subscribe to updates of instance parameters
        if hasattr(self, 'update'):
            self.iparv.attach(self)
            self.update(self.ipar)
Exemple #2
0
    @property
    def V(self):
        return Quantity('V', self)

    @property
    def I(self):
        return Quantity('I', self)

    def __repr__(self):
        return 'Branch(' + repr(self.plus) + ',' + repr(self.minus) + ')'


### Default reference node
gnd = Node("gnd", isglobal=True)

defaultepar = ParameterDict(
    Parameter("T", "Temperature", unit="K", default=300))


class Circuit(object):
    """Basic circuit class 

    The circuit class models electric circuits but could be used for
    any conservative system. A circuit object contains a list of nodes and
    branches which are associated with node voltages and branch currents in the
    modelled system. Note that the values of these quantities are
    stored in separate analysis classes, never inside a circuit object.

    The nodes are connected to the outside through terminals. When the circuit
    is instanciated, the outside nodes are passed to the object via the 
    terminals.
Exemple #3
0
 def __init__(self, sim, **parvalues):
     self.sim = sim
     self.par = ParameterDict(*self.parameters, **parvalues)