MCPcopy Create free account
hub / github.com/SLiCAP/SLiCAP_python / _makeSrcVector

Function _makeSrcVector

SLiCAP/SLiCAPmatrices.py:330–406  ·  view source on GitHub ↗

Creates the vector with independent variables. The vector can be created for a single independent variable or for all. This can be used for determination of a transfer using Cramer's rule. If a single variable is used, this vector and Cramer's rule can be used as an alternativ

(cir, parDefs, elid, value='id', numeric=True, substitute=True)

Source from the content-addressed store, hash-verified

328 return (M, Dv)
329
330def _makeSrcVector(cir, parDefs, elid, value='id', numeric=True, substitute=True):
331 """
332 Creates the vector with independent variables.
333 The vector can be created for a single independent variable or for all.
334
335 This can be used for determination of a transfer using Cramer's rule.
336
337 If a single variable is used, this vector and Cramer's rule can be used as
338 an alternative for calculation cofactors:
339
340 The refDes of the independent variable (source) is substituted in the vecor
341 with independent variables (value = 'id'). This vector is then substituted
342 in the detector col, of the MNA matrix. After calculation of the
343 determinant of this modified matrix, the result is divided by refDes.
344
345 This method is used for determination of gain factors for noise sources
346 and for DC variance sources.
347
348 :param cir: Circuit of which the matrices need to be returned.
349 :type cir: SLiCAPprotos.circuit
350
351 :param parDefs: Dict with key value pairs:
352
353 - key : parameter name (sympy.Symbol)
354 - value: numeric value of sympy expression
355 :type parDefs: dict
356
357 :param elid: Refdes (ID) of a source to be included in this vector; 'all'
358 for all sources.
359 :type elid: str
360
361 :param numeric: If True is uses full substitution and sympy.N for converting
362 parameters to sympy floats
363 :type numeric: bool
364
365 :return: Iv: vector with in dependent variables
366 :return type: sympy.Matrix
367 """
368 # varIndex holds the position of dependent variables in the matrix.
369 varIndex = _createDepVarIndex(cir)
370 dim = len(list(varIndex.keys()))
371 # Define the vector
372 Iv = [0 for i in range(dim)]
373 # Select the elements of interest
374 if elid == 'all':
375 elements = [cir.elements[key] for key in list(cir.elements.keys())]
376 elif elid in list(cir.elements.keys()):
377 elements = [cir.elements[elid]]
378 for elmt in elements:
379 # subsititute the element parameters of interest in the vecor Iv
380 if value == 'id':
381 if elid == 'all':
382 val = sp.Symbol(elmt.refDes)
383 else:
384 val = 1
385 elif value == 'value':
386 val = _getValue(elmt, 'value', numeric, parDefs, substitute)
387 elif value == 'noise':

Callers 1

_makeAllMatricesFunction · 0.90

Calls 3

float2rationalFunction · 0.90
_createDepVarIndexFunction · 0.85
_getValueFunction · 0.85

Tested by

no test coverage detected