Exemple #1
0
def test_bug():
    x1 = Symbol('x1')
    x2 = Symbol('x2')
    y = x1 * x2
    assert y.subs(x1, Float(3.0)) == Float(3.0) * x2
Exemple #2
0
# Transfer function
K, J, b, R, L = sym.symbols('K J b R L')
G = K / (s * ((J * s + b) * (L * s + R) + K**2))
G = G.subs([(K, 0.0274), (J, 3.2284E-6), (b, 3.5077E-6), (R, 4), (L, 2.75E-6)])

# Calculate response
Y = G * U

# Inverse Laplace Transform
u = inverse_laplace_transform(U, s, t)
y = inverse_laplace_transform(Y, s, t)

# generate data for plot
tm = np.linspace(0, 8, 100)
us = np.zeros(len(tm))
ys = np.zeros(len(tm))

# substitute numeric values for u and y
for i in range(len(tm)):
    us[i] += u.subs(t, tm[i])
    ys[i] += y.subs(t, tm[i])

# Plot the results
plt.figure()
plt.plot(tm, us, label='u(t)')
plt.plot(tm, ys, label='y(t)')
plt.legend()
plt.xlabel('Time')
plt.show()
Exemple #3
0
def test_bug():
    x1 = Symbol("x1")
    x2 = Symbol("x2")
    y = x1 * x2
    assert y.subs(x1, Float(3.0)) == Float(3.0) * x2
Exemple #4
0
def test_bug():
    x1 = Symbol('x1')
    x2 = Symbol('x2')
    y = x1*x2
    assert y.subs(x1, Float(3.0)) == Float(3.0)*x2
Exemple #5
0
def test_bug():
    x1 = Symbol("x1")
    x2 = Symbol("x2")
    y = x1 * x2
    assert y.subs(x1, Float(3.0)) == Float(3.0) * x2