MCPcopy Index your code
hub / github.com/SLiCAP/SLiCAP_python / findServoBandwidth

Function findServoBandwidth

SLiCAP/SLiCAPmath.py:413–499  ·  view source on GitHub ↗

Determines the intersection points of the asymptotes of the magnitude of the loopgain with unity. :param loopgainRational: Rational function of the Laplace variable, that represents the loop gain of a circuit. :type LoopgainRational: sympy.Expr :return: Dictionary w

(loopgainRational)

Source from the content-addressed store, hash-verified

411 return gain
412
413def findServoBandwidth(loopgainRational):
414 """
415 Determines the intersection points of the asymptotes of the magnitude of
416 the loopgain with unity.
417
418 :param loopgainRational: Rational function of the Laplace variable, that
419 represents the loop gain of a circuit.
420 :type LoopgainRational: sympy.Expr
421
422 :return: Dictionary with key-value pairs:
423
424 - hpf: frequency of high-pass intersection
425 - hpo: order at high-pass intersection
426 - lpf: frequency of low-pass intersection
427 - lpo: order at low-pass intersection
428 - mbv: mid-band value of the loopgain (highest value at order = zero)
429 - mbf: lowest freqency of mbv
430 :rtype: dict
431 """
432 numer, denom = loopgainRational.as_numer_denom()
433 poles = _numRoots(denom, ini.laplace)
434 zeros = _numRoots(numer, ini.laplace)
435 poles, zeros = _cancelPZ(poles, zeros)
436 numPoles = len(poles)
437 numZeros = len(zeros)
438 numCornerFreqs = numPoles + numZeros
439 gain, coeffsN, coeffsD = coeffsTransfer(loopgainRational)
440 freqsOrders = np.zeros((numCornerFreqs, 2), dtype='float64')
441 for i in range(numZeros):
442 freqsOrders[i, 0] = np.abs(zeros[i])
443 freqsOrders[i, 1] = 1
444 for i in range(numPoles):
445 freqsOrders[numZeros + i, 0] = np.abs(poles[i])
446 freqsOrders[numZeros + i, 1] = -1
447 # sort the rows with increasing corner frequencies
448 freqsOrders = freqsOrders[freqsOrders[:, 0].argsort()]
449 for i in range(numCornerFreqs):
450 if i == 0:
451 # Initialize variables
452 value = np.abs(float(gain))
453 fcorner = float(freqsOrders[i, 0])
454 order = int(freqsOrders[i, 1])
455 result = _initServoResults(fcorner, order, value)
456 elif freqsOrders[i, 0] == 0:
457 # Update corner frequency and order
458 fcorner = float(freqsOrders[i, 0])
459 order += int(freqsOrders[i, 1])
460 else:
461 new_fcorner = float(freqsOrders[i, 0])
462 new_order = int(order + freqsOrders[i, 1])
463 # Determine new value at corner frequency
464 if order == 0:
465 new_value = value
466 elif fcorner == 0: # first pole or zero in origin
467 new_value = value * new_fcorner ** order
468 else:
469 new_value = value * (new_fcorner / fcorner) ** order
470 # Determine unity-gain frequencies

Callers 1

phaseMarginFunction · 0.85

Calls 4

_numRootsFunction · 0.85
_cancelPZFunction · 0.85
coeffsTransferFunction · 0.85
_initServoResultsFunction · 0.85

Tested by

no test coverage detected