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

Function equateCoeffs

SLiCAP/SLiCAPmath.py:1217–1296  ·  view source on GitHub ↗

Returns the solutions of the equation transferFunction = protoTypeFunction. Both transfer and prototype should be Laplace rational functions. Their numerators should be polynomials of the Laplace variable of equal order and their denominators should be polynomials of the Laplace va

(protoType, transfer, noSolve=[], numeric=True)

Source from the content-addressed store, hash-verified

1215 return M
1216
1217def equateCoeffs(protoType, transfer, noSolve=[], numeric=True):
1218 """
1219 Returns the solutions of the equation transferFunction = protoTypeFunction.
1220
1221 Both transfer and prototype should be Laplace rational functions.
1222 Their numerators should be polynomials of the Laplace variable of equal
1223 order and their denominators should be polynomials of the Laplace variable
1224 of equal order.
1225
1226 :param protoType: Prototype rational expression of the Laplace variable
1227 :type protoType: sympy.Expr
1228 :param transfer:
1229
1230 Transfer fucntion of which the parameters need to be
1231 solved. The numerator and the denominator of this rational
1232 expression should be of the same order as those of the
1233 prototype.
1234
1235 :type transfer: sympy.Expr
1236
1237 :param noSolve: List with variables (*str, sympy.core.symbol.Symbol*) that do not need
1238 to be solved. These parameters will remain symbolic in the
1239 solutions.
1240
1241 :type noSolve: list
1242
1243 :param numeric: True will convert numeric results with floats instead of rationals
1244
1245 :type numeric: bool
1246
1247 :return: Dictionary with key-value pairs:
1248
1249 - key: name of the parameter (*sympy.core.symbol.Symbol*)
1250 - value: solution of this parameter: (*sympy.Expr, int, float*)
1251
1252 :rtype: dict
1253 """
1254 values = {}
1255 pars = list(set(list(protoType.atoms(sp.Symbol)) +
1256 list(transfer.atoms(sp.Symbol))))
1257 for i in range(len(noSolve)):
1258 noSolve[i] = sp.Symbol(str(noSolve[i]))
1259 params = []
1260 for par in pars:
1261 if par != ini.laplace and par not in noSolve:
1262 params.append(par)
1263 gainP, pN, pD = coeffsTransfer(protoType)
1264 gainT, tN, tD = coeffsTransfer(transfer)
1265 if len(pN) != len(tN) or len(pD) != len(tD):
1266 print('Error: unequal orders of prototype and target.')
1267 equations = []
1268 for i in range(len(pN)):
1269 eqn = sp.Eq(pN[i], tN[i])
1270 if eqn != True:
1271 equations.append(eqn)
1272 for i in range(len(pD)):
1273 eqn = sp.Eq(pD[i], tD[i])
1274 if eqn != True:

Callers

nothing calls this directly

Calls 1

coeffsTransferFunction · 0.85

Tested by

no test coverage detected