Syntax for solving a system of differential equations in sympy
I'm new to sympathy and learning about it. I have been looking through the documentation and questions in stack exchange regarding symbolically solving a system of differential equations with initial conditions using sympy.
I have a simple ODE-s system
( dV/dt ) = -( 1 / RC ) * ( V(t) ) + I(t)/C
( dI/dt ) = -( R1 / L ) * ( I(t) ) - ( 1 / L) * V(t) + Vs/L
with initial conditions V(0) = V0
andI(0) = I0
I have looked through many questions in stack exchange and could not find a suitable answer. It would be very helpful if someone could show me the syntax to get into a system of linked differential equations with initial conditions.
source to share
ODE support is only supported in SymPy. It will be added in 0.7.6. The syntax would be
V, I = symbols("V I", cls=Function)
RC, t, C, Vs, L, R1, V0, I0 = symbols("RC t C Vs L R1 V0 I0")
system = [Eq(V(t).diff(t), -1/RC*V(t) + I(t)/C), Eq(I(t).diff(t), -R1/L*I(t) - 1/L*V(t) + Vs/L)]
ics = {V(0): V0, I(0): I0}
dsolve(system, [V(t), I(t)], ics=ics)
There seems to be a bug that prevents this from working in the current main SymPy, unless I typed something ( https://github.com/sympy/sympy/issues/8193 ).
source to share