Ik heb de indruk dat het "stationaire" verloop redelijk klopt. Dan zou de fout misschien in de begincondities kunnen zitten.
Wat heb je voor IL en UC op t=0?
Moderator: Rhiannon
Maar mijn stationaire oplossing komt niet overeen met die van ukster.
Hier klopt iets niet. I1=1 A (beginconditie t=0)
Code: Selecteer alles
import sympy as sp
import numpy as np
import matplotlib.pyplot as plt
i, u2, i1, i2 = sp.symbols('i u2 i1 i2', cls=Function)
L, R1, R2, C, t = sp.symbols('L R1 R2 C t')
R1=15
R2=5
L=1
C=0.1
eq1 = L*(i1(t).diff(t) + i2(t).diff(t)) + R1 *i1(t) - 10*cos(t/3)
eq2 = R1*(i1(t).diff(t)) - R2 * (i2(t).diff(t)) - i1(t) / C
sol = sp.dsolve([eq1, eq2], [i1(t), i2(t)])
i1=sol[0].rhs
i2=sol[1].rhs
C1, C2 = sp.symbols("C1, C2")
eq1 = i1.subs(t,0) - 1
eq2 = i2.subs(t,1) + 1
sol = sp.solve([eq1, eq2], [C1, C2])
i1=i1.subs('C1', sol[C1]).subs('C2', sol[C2])
i2=i2.subs('C1', sol[C1]).subs('C2', sol[C2])
# Step 2: Convert the symbolic expression to a numerical function
i1_num = sp.lambdify(t, i1, "numpy")
i2_num = sp.lambdify(t, i2, "numpy")
# Step 3: Define the range for x values using NumPy
t_vals = np.linspace(0, 20, 400) # Avoid x = 0 due to log(x)
# Step 4: Evaluate the function over the range of x values
i1_vals = i1_num(t_vals)
i2_vals = i2_num(t_vals)
# Step 5: Plot the function using Matplotlib
plt.plot(t_vals, i1_vals, label=r'i1')
plt.plot(t_vals, i2_vals, label=r'i2')
plt.xlabel('t')
plt.ylabel('i(t)')
plt.title('Plot of the currents')
plt.legend()
plt.grid(True)
plt.show()
Code: Selecteer alles
from sympy import *
i, u2, i1, i2 = symbols('i u2 i1 i2', cls=Function)
L, R1, R2, C, t = symbols('L R1 R2 C t')
R1=15
R2=5
L=1
C=0.1
eq1 = 10*cos(t/3)-i1(t).diff(t)
eq2 = i2(t).diff(t)-10
sol = dsolve([eq1, eq2], [i1(t), i2(t)])
i1=sol[0].rhs
i2=sol[1].rhs
C1, C2 = sp.symbols("C1, C2")
eq1 = i1.subs(t,0) - 1
eq2 = i2.subs(t,1) + 1
sol = sp.solve([eq1, eq2], [C1, C2])
i1=i1.subs('C1', sol[C1]).subs('C2', sol[C2])
i2=i2.subs('C1', sol[C1]).subs('C2', sol[C2])
Code: Selecteer alles
from sympy import *
i, u2, i1, i2 = symbols('i u2 i1 i2', cls=Function)
L, R1, R2, C, t = symbols('L R1 R2 C t')
R1=15
R2=5
L=1
C=0.1
ode1 = 10*cos(t/3)-i1(t).diff(t)
ode2 = i2(t).diff(t)-10
sol1 = dsolve([eq1, eq2], [i1(t), i2(t)])
checkodesol([ode1, ode2], sol1)
Code: Selecteer alles
import sympy as sp
import numpy as np
import matplotlib.pyplot as plt
i, u2, i1, i2 = sp.symbols('i u2 i1 i2', cls=Function)
L, R1, R2, C, t = sp.symbols('L R1 R2 C t')
R1=15
R2=5
L=1
C=0.1
ode1 = L*(i1(t).diff(t) + i2(t).diff(t)) + R1 *i1(t) - 10*cos(t/3)
ode2 = R1*(i1(t).diff(t)) - R2 * (i2(t).diff(t)) - i1(t) / C
sol1 = sp.dsolve([ode1, ode2], [i1(t), i2(t)])
checkodesol([ode1, ode2], sol1)