I have a simple electrical circuit of an ideal transformer:
I model it in Mathematica 11.3 with the idea to solve for secondary current and potential difference. Here is my code:
ClearAll["Global`*"]
time = 0.001;
r1 = 0.5;
r2 = 1000;
l1 = 0.001;
l2 = 0.1;
m = Sqrt[l1*l2];
vSource[t_] = 20 Sin[10000*Pi* t];
eq1 = vSource[t] == i1[t]*r1 + l1*i1'[t] - m*i2'[t];
eq2 = m*i1'[t] == i2[t]*r2 + l2*i2'[t];
ic1 = i1[0] == 0;
ic2 = i2[0] == 0;
sol = NDSolveValue[{eq1, eq2, ic1, ic2}, i2, {t, 0, time}];
Plot[sol[t], {t, 0, time}, PlotLabel -> "Current through r2"]
Plot[sol[t]*r2, {t, 0, time}, PlotLabel -> "Potential difference across r2"]
And here is the plotted solution:
which corresponds to my LTSpice solution:
Now my problem is that I get the following warning:
NDSolveValue::ntdvdae: Cannot solve to find an explicit formula for the derivatives. NDSolve will try solving the system as differential-algebraic equations.
Despite getting the solution, warning signifies that I am doing something wrong. Could anyone please help solve my problem properly and explain why I get the warning?
{eq1,eq2}
in an explicit form you'll recognize some problems. That's the error message MMA shows! $\endgroup$l1 l2 - m^2=0
. Therefore Mathematica gives a warning. Do not pay attention, it is still a solution to the equations in this case. $\endgroup$m = 0.99 Sqrt[l1 l2]
. Then there is no warning anymore. The solver doesn't commute to the DAE Solver, which is a good thing because the DAE solver is not very robust (and useless in this case), and physically it is realistic. $\endgroup$