I am using sympy to be able to perform Laplace/Inverse Laplace transforms for a controls class. Currently I am using the inverse Laplace but am having the error shown below my code. I believe the issue has something to do with the package and not my code but I am unsure.
from sympy.integrals.transforms import inverse_laplace_transform
from sympy import exp, Symbol
from sympy.plotting import plot
from sympy.abc import s, t
a = Symbol('a', positive = True)
G_d = 0.5*exp(-30*s)/(60*s + 1)
G_t = 1
G_f_a = -0.25
G_f_b = -0.25*exp(-10*s)*(95*s + 1)/(60*s + 1)
G_v = 1
G_p = 2*exp(-20*s)/(95*s + 1)
G_m = 1
G_c = 95 + 95/(10*s)
TF1 = (G_d + G_t*G_f_a*G_v*G_p)/(1 + G_c*G_v*G_p*G_m)/s
TF2 = (G_d + G_t*G_f_b*G_v*G_p)/(1 + G_c*G_v*G_p*G_m)/s
y1 = inverse_laplace_transform(TF1, s, t)
y2 = inverse_laplace_transform(TF2, s, t)
plot(y1, y2, (t, 0, 500))
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
File "C:\Users\jj\OneDrive\Documents\Spring 2023\15-10.py", line 30, in plot(y1, y2, (t, 0, 500))
File "C:\Users\jj\anaconda3\envs\rdkit_env\Lib\site-packages\sympy\plotting\plot.py", line 1873, in plot plots.show()
File "C:\Users\jj\anaconda3\envs\rdkit_env\Lib\site-packages\sympy\plotting\plot.py", line 251, in show self._backend.show()
File "C:\Users\jj\anaconda3\envs\rdkit_env\Lib\site-packages\sympy\plotting\plot.py", line 1549, in show self.process_series()
File "C:\Users\jj\anaconda3\envs\rdkit_env\Lib\site-packages\sympy\plotting\plot.py", line 1546, in process_series self._process_series(series, ax, parent)
File "C:\Users\jj\anaconda3\envs\rdkit_env\Lib\site-packages\sympy\plotting\plot.py", line 1367, in _process_series x, y = s.get_data()
File "C:\Users\jj\anaconda3\envs\rdkit_env\Lib\site-packages\sympy\plotting\plot.py", line 605, in get_data points = self.get_points()
File "C:\Users\jj\anaconda3\envs\rdkit_env\Lib\site-packages\sympy\plotting\plot.py", line 779, in get_points f_start = f(self.start)
File "C:\Users\jj\anaconda3\envs\rdkit_env\Lib\site-packages\sympy\plotting\experimental_lambdify.py", line 188, in call return self.call(args)
File "C:\Users\jj\anaconda3\envs\rdkit_env\Lib\site-packages\sympy\plotting\experimental_lambdify.py", line 196, in call return self.call(args)
File "C:\Users\jj\anaconda3\envs\rdkit_env\Lib\site-packages\sympy\plotting\experimental_lambdify.py", line 184, in call raise e
File "C:\Users\jj\anaconda3\envs\rdkit_env\Lib\site-packages\sympy\plotting\experimental_lambdify.py", line 176, in call result = complex(self.lambda_func(args))
File "C:\Users\jj\anaconda3\envs\rdkit_env\Lib\site-packages\sympy\plotting\experimental_lambdify.py", line 272, in call return self.lambda_func(*args, **kwargs)
File "", line 1, in
File "C:\Users\jj\anaconda3\envs\rdkit_env\Lib\site-packages\sympy\core\expr.py", line 356, in complex return complex(float(re), float(im))
File "C:\Users\jj\anaconda3\envs\rdkit_env\Lib\site-packages\sympy\core\expr.py", line 351, in float raise TypeError("Cannot convert expression to float")
TypeError: Cannot convert expression to float
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
When my variable G_c is set to 0, the code runs fine and I get the correct plots, however, with any value other than 0, I get the "cannot convert expression to float" error. The plot should come looking similar to the one shown below.Plot for G_c = 0, plot for G_c other than 0 should look similar