gpt4 book ai didi

python - 错误 : can't get the inverse laplace transform expression with sympy

转载 作者:行者123 更新时间:2023-12-05 05:56:51 24 4
gpt4 key购买 nike

我一直在尝试使用 sympy 为以下传递函数 wlt 计算逆拉普拉斯变换:

                             -2⋅s         
(1.0e-8⋅s + 0.02)⋅ℯ
────────────────────────────────────────
⎛ 2 ⎞
s⋅⎝1.0e-11⋅s + 2.0000003e-5⋅s + 0.00177⎠

用下一个表达式:

wtl_t = sp.inverse_laplace_transform(wtl, s, t, noconds=True)

在哪里

s = sp.symbols('s')
t = sp.symbols('t', positive=True)

但是当我运行代码时,出现了这个错误:

Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/sympy/polys/polyutils.py", line 211, in _parallel_dict_from_expr_if_gens
monom[indices[base]] = exp
KeyError: RisingFactorial(_t + 1, 1.0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/sympy/polys/partfrac.py", line 81, in apart
(P, Q), opt = parallel_poly_from_expr((P, Q), x, **options)
File "/usr/local/lib/python3.9/dist-packages/sympy/polys/polytools.py", line 4340, in parallel_poly_from_expr
return _parallel_poly_from_expr(exprs, opt)
File "/usr/local/lib/python3.9/dist-packages/sympy/polys/polytools.py", line 4393, in _parallel_poly_from_expr
reps, opt = _parallel_dict_from_expr(exprs, opt)
File "/usr/local/lib/python3.9/dist-packages/sympy/polys/polyutils.py", line 332, in _parallel_dict_from_expr
reps, gens = _parallel_dict_from_expr_if_gens(exprs, opt)
File "/usr/local/lib/python3.9/dist-packages/sympy/polys/polyutils.py", line 216, in _parallel_dict_from_expr_if_gens
raise PolynomialError("%s contains an element of "
sympy.polys.polyerrors.PolynomialError: RisingFactorial(_t + 1, 1.0) contains an element of the set of generators.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/mnt/hgfs/FACULTAD/3er año/SDC/S&C_withPython/SDC_ex/GTP2_ex3.py", line 62, in <module>
wtl_t = sp.inverse_laplace_transform(wtl, s, t, noconds=True)
File "/usr/local/lib/python3.9/dist-packages/sympy/integrals/transforms.py", line 1341, in inverse_laplace_transform
return InverseLaplaceTransform(F, s, t, plane).doit(**hints)
File "/usr/local/lib/python3.9/dist-packages/sympy/integrals/transforms.py", line 130, in doit
return self._compute_transform(self.function,
File "/usr/local/lib/python3.9/dist-packages/sympy/integrals/transforms.py", line 1287, in _compute_transform
return _inverse_laplace_transform(F, s, t, self.fundamental_plane, **hints)
File "/usr/local/lib/python3.9/dist-packages/sympy/integrals/transforms.py", line 218, in wrapper
res = func(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/sympy/integrals/transforms.py", line 1213, in _inverse_laplace_transform
f, cond = inverse_mellin_transform(F, s, exp(-t), (None, oo),
File "/usr/local/lib/python3.9/dist-packages/sympy/integrals/transforms.py", line 908, in inverse_mellin_transform
return InverseMellinTransform(F, s, x, strip[0], strip[1]).doit(**hints)
File "/usr/local/lib/python3.9/dist-packages/sympy/integrals/transforms.py", line 130, in doit
return self._compute_transform(self.function,
File "/usr/local/lib/python3.9/dist-packages/sympy/integrals/transforms.py", line 846, in _compute_transform
return _inverse_mellin_transform(F, s, x, strip, **hints)
File "/usr/local/lib/python3.9/dist-packages/sympy/integrals/transforms.py", line 218, in wrapper
res = func(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/sympy/integrals/transforms.py", line 773, in _inverse_mellin_transform
h = hyperexpand(G)
File "/usr/local/lib/python3.9/dist-packages/sympy/simplify/hyperexpand.py", line 2513, in hyperexpand
return f.replace(hyper, do_replace).replace(meijerg, do_meijer)
File "/usr/local/lib/python3.9/dist-packages/sympy/core/basic.py", line 1497, in replace
rv = walk(self, rec_replace)
File "/usr/local/lib/python3.9/dist-packages/sympy/core/basic.py", line 1481, in walk
rv = F(rv)
File "/usr/local/lib/python3.9/dist-packages/sympy/core/basic.py", line 1490, in rec_replace
v = _value(expr, result)
File "/usr/local/lib/python3.9/dist-packages/sympy/core/basic.py", line 1419, in <lambda>
_value = lambda expr, result: value(*expr.args)
File "/usr/local/lib/python3.9/dist-packages/sympy/simplify/hyperexpand.py", line 2509, in do_meijer
r = _meijergexpand(G_Function(ap[0], ap[1], bq[0], bq[1]), z,
File "/usr/local/lib/python3.9/dist-packages/sympy/simplify/hyperexpand.py", line 2394, in _meijergexpand
slater2, cond2 = do_slater(tr(func.bm), tr(func.an), tr(func.bq), tr(func.ap),
File "/usr/local/lib/python3.9/dist-packages/sympy/simplify/hyperexpand.py", line 2320, in do_slater
hyp = _hyperexpand(Hyper_Function(nap, nbq), harg, ops,
File "/usr/local/lib/python3.9/dist-packages/sympy/simplify/hyperexpand.py", line 2061, in _hyperexpand
formula = try_lerchphi(func)
File "/usr/local/lib/python3.9/dist-packages/sympy/simplify/hyperexpand.py", line 1799, in try_lerchphi
part = apart(numer/denom, t)
File "/usr/local/lib/python3.9/dist-packages/sympy/utilities/decorator.py", line 34, in threaded_func
return func(expr, *args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/sympy/polys/partfrac.py", line 84, in apart
raise PolynomialError(msg)
sympy.polys.polyerrors.PolynomialError: RisingFactorial(_t + 1, 1.0) contains an element of the set of generators.

我也尝试使用部分分数并分解 TF,但没有任何反应。

最佳答案

我在 sp.inverse_laplace_transform(...) 中遇到了类似的错误,将 Sympy 从 1.9 降级到 1.7.1 有帮助。

关于python - 错误 : can't get the inverse laplace transform expression with sympy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68990699/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com