Question: ERROR in dsolve numeric: unable to store '...' when datatype=float[8]

Hello everyone,

I want to solve a simple ODE numerically having a piecewise periodic function in the ODE.

The periodic piecewise function definition is taken from this  post.

When solving using "dsolve" numerical, I get this error:

Error, (in f) unable to store '100000*square_wave_periodic' when datatype=float[8]

restart;
d := .5;
fs := 100*10^3;
Vin := 10;
C := 10*10^(-6);
R := 10;
L := 10*10^(-6);

DEFINE PERIODIC FUNCTION
square_wave := proc (t) options operator, arrow; piecewise(0 <= t and t <= d/fs, Vin, d/fs < t and t < 1/fs, 0) end proc

square_wave_periodic := proc (t) options operator, arrow; square_wave(t-floor(t*fs)/fs) end proc

ode1 := L*(diff(i(t), t))+v(t) = square_wave_periodic
ode2 := C*(diff(v(t), t))+v(t)/R = i(t)
IC := v(0) = 0, i(0) = 0
sol := dsolve({IC, ode1, ode2}, {i(t), v(t)}, numeric)

LCRcircuit_transient_numerical.mw

Any help is much appreciated ! Thank you !

Please Wait...