Chemza's post 23 Jan 11 11:36 described expected output for an R-L circuit. His earlier posts were not clear but I
assume when he said the simulator wouldn't work he meant that it just wasn't giving the results he expected.
Maple have a number of options for dsolve... if you want a specific numeric solution method there are extra arguments to dsolve, but if you don't use any it uses a symbolic method and the solution is symbolic:
i.e. dsolve({subs({L=1,R=10},DiffEqn),i(0)=0},i(t)) outputs the following exact algebraic solution, just as if you had solved it by hand:
Code:
i(t) = 1/10 Heaviside(t) - 1/5 Heaviside(t - 1)
+ 1/5 Heaviside(t - 2) - 1/5 Heaviside(t - 3)
+ 1/5 Heaviside(t - 4) - 1/5 exp(-10 t + 140) Heaviside(t - 14)
- 1/5 Heaviside(t - 5) + 1/5 Heaviside(t - 6)
- 1/5 Heaviside(t - 7) + 1/5 Heaviside(t - 8)
- 1/5 exp(-10 t + 100) Heaviside(t - 10) - 1/5 Heaviside(t - 9)
+ 1/5 Heaviside(t - 10) - 1/5 Heaviside(t - 11)
+ 1/5 exp(-10 t + 10) Heaviside(t - 1)
- 1/5 exp(-10 t + 200) Heaviside(t - 20)
+ 1/5 exp(-10 t + 190) Heaviside(t - 19)
+ 1/5 exp(-10 t + 70) Heaviside(t - 7)
+ 1/5 exp(-10 t + 130) Heaviside(t - 13)
+ 1/5 exp(-10 t + 50) Heaviside(t - 5)
+ 1/5 exp(-10 t + 30) Heaviside(t - 3)
- 1/5 exp(-10 t + 40) Heaviside(t - 4)
+ 1/5 exp(-10 t + 110) Heaviside(t - 11)
- 1/5 exp(-10 t + 60) Heaviside(t - 6) + 1/5 Heaviside(t - 12)
- 1/5 Heaviside(t - 13) + 1/5 Heaviside(t - 14)
- 1/5 Heaviside(t - 15) - 1/5 exp(-10 t + 120) Heaviside(t - 12)
+ 1/5 Heaviside(t - 16) - 1/5 Heaviside(t - 17)
- 1/5 exp(-10 t + 160) Heaviside(t - 16) + 1/5 Heaviside(t - 18)
- 1/5 Heaviside(t - 19) + 1/5 Heaviside(t - 20)
+ 1/5 exp(-10 t + 150) Heaviside(t - 15)
+ 1/5 exp(-10 t + 170) Heaviside(t - 17)
+ 1/5 exp(-10 t + 90) Heaviside(t - 9)
- 1/5 exp(-10 t + 20) Heaviside(t - 2)
- 1/10 exp(-10 t) Heaviside(t)
- 1/5 exp(-10 t + 80) Heaviside(t - 8)
- 1/5 exp(-10 t + 180) Heaviside(t - 18)
The problem is not particularly challenging for a numeric solution. ODE solutions of d/dt(x(t),t) = f(x(t),t) fall into the categories of explicit and implicit.
The forward Euler method is an example of explicit:
X(t+h) = X(t) + f(X(t))
It will not fail as long as there is a solution f(X(t)) which does not blow up. An iterative explicit variable step size routine would decrease step size to the minimum around the step-changes in V(t), but wouldn't have any problems generating a solution.
Matlab's ode45 is a more common example of explicit method.
The backward Euler method is an example of implicit method:
X(t+h) = X(t) + f(X(t+h))
it is not a straightforward calc since X(t+h) is only implitly defined.
I think most circuit solvers use the trapezoidal method which is also an implicit method:
X(t+h) = X(t) + 0.5*(f(X(t) + f(X(t+h))
It is also an implicit technique since there is no explicit formula for X(t+h).
For an inductor
I(t+h) = I(t) + 0.5*(V(t) + V(t+h))/L
The problem is V(t+h) is not necessarily known without I(t)
If we solve for 2 variables I(t+h) and V(t+h) in terms of the variables I(t), V(t), we have a relationship between I(t+h) and V(t+h) in terms of known quantities (V(t), I(t), L). This resembles an impedance relationship in terms of h and can be collected together in an impedance matrix and inverted. I assume the inversion step is where the problem occurs in circuit solvers which use an implicit integration method. Again should be no problem for explicit methods.
Sorry if this is more than you wanted. If you have any insight on the error you were talking about I'd be interested to hear... I was guessing as to the cause (matrix inversion)
=====================================
(2B)+(2B)' ?