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

Function _doPyLoopGainServo

SLiCAP/SLiCAPexecute.py:1551–1600  ·  view source on GitHub ↗
(instr)

Source from the content-addressed store, hash-verified

1549 return instr
1550
1551def _doPyLoopGainServo(instr):
1552 if instr.lgValue[0] != None:
1553 lg1 = instr.lgValue[0]
1554 else:
1555 lg1 = sp.N(0)
1556 if instr.lgValue[1] != None:
1557 lg2 = instr.lgValue[1]
1558 else:
1559 lg2 = sp.N(0)
1560 if instr.convType !=None and instr.removePairSubName:
1561 lenExt = len(instr.pairExt[0])
1562 params = list(set(list(lg1.atoms(sp.Symbol)) + list(lg2.atoms(sp.Symbol))))
1563 substDict = {}
1564 for param in params:
1565 parName = str(param)
1566 if len(parName) > lenExt:
1567 if parName[-lenExt:] in instr.pairExt:
1568 substDict[param] = sp.Symbol(parName[:-lenExt])
1569 lg1 = lg1.xreplace(substDict)
1570 lg2 = lg2.xreplace(substDict)
1571 if instr.substitute:
1572 lg1 = fullSubs(lg1, instr.parDefs)
1573 lg2 = fullSubs(lg2, instr.parDefs)
1574 if instr.numeric:
1575 lg1 = float2rational(sp.N(lg1))
1576 lg2 = float2rational(sp.N(lg2))
1577 _LGREF_1, _LGREF_2 = sp.symbols('_LGREF_1, _LGREF_2')
1578 MD = instr.M
1579 M0 = instr.M.xreplace({_LGREF_1: 0, _LGREF_2: 0})
1580 DM = det(MD, method=ini.denom)
1581 D0 = det(M0, method=ini.denom)
1582 LG = (D0-DM)/D0
1583 if instr.substitute:
1584 LG = fullSubs(LG, instr.parDefs)
1585 if instr.numeric:
1586 LG = float2rational(sp.N(LG))
1587 num, den = LG.as_numer_denom()
1588 LG = sp.simplify(num/den).xreplace({_LGREF_1: lg1, _LGREF_2: lg2})
1589 num, den = LG.as_numer_denom()
1590 if instr.gainType == 'loopgain':
1591 instr.laplace.append(LG)
1592 elif instr.gainType == 'servo':
1593 SVnum = - num
1594 SVden = sp.expand(den - num)
1595 num, den = SVnum, SVden
1596 SV = num/den
1597 instr.laplace.append(SV)
1598 instr.numer.append(num)
1599 instr.denom.append(den)
1600 return instr
1601
1602def _doPyNoise(instr):
1603 s2f = 2*sp.pi*sp.I*sp.Symbol('f', positive=True)

Callers 4

_doNumerFunction · 0.85
_doDenomFunction · 0.85
_doLaplaceFunction · 0.85
_doDCFunction · 0.85

Calls 3

fullSubsFunction · 0.90
float2rationalFunction · 0.90
detFunction · 0.90

Tested by

no test coverage detected